littlebizzy / slickstack

Lightning-fast WordPress on Nginx
https://slickstack.io
GNU General Public License v3.0
629 stars 112 forks source link

Unwanted sync between dev and production databases #122

Closed Syncriix closed 2 years ago

Syncriix commented 2 years ago

Steps to reproduce:

Ref: Pic 1 image Ref: Pic 2 image image

I guess it might use the same database by mistake?

jessuppi commented 2 years ago

@Syncriix Thanks for the detailed report and discussion via our chat room too :)

So, the first thing is there was a bug in the wp-config.php files being installed for staging/dev sites, now fixed:

Ref: https://github.com/littlebizzy/slickstack/blob/master/modules/wordpress/wp-config-dev.txt Ref: https://github.com/littlebizzy/slickstack/blob/master/modules/wordpress/wp-config-staging.txt

...they were using the same database as production, without the suffix _staging and _dev they were supposed to use.

However, the bigger fix here is that we've changed to using new database names for staging/dev sites that are now hardcoded to be named "staging" and "development" and cannot be changed. This serves a few purposes like:

So going forward, the ss-install setup wizard will ask users what they want to name the production database, and the default name will now be "production" instead of "wordpress"...

So by default, SlickStack now has only 1 MySQL database called "production" unless the sysadmin enables staging/dev sites in which case there will be 3 MySQL databases installed to the server. Later if they want to disable staging/dev then they can easily delete those extra databases without worrying about doing janky surgery on the production database.

jessuppi commented 2 years ago

There was also a similar bug in ss-install-mysql-database as well, now also fixed:

Ref: https://github.com/littlebizzy/slickstack/blob/master/bash/ss-install-mysql-database.txt

This script is now hardcoded to create databases "staging" and "development" only if staging/dev sites are enabled. However, the name of the production database depends on ss-config settings.

Syncriix commented 2 years ago

Thanks for the quick fix! I will test and confirm tomorrow and close the issue

jessuppi commented 2 years ago

I will close out this Issue but just FYI there might still be a few of our bash scripts that need more "if statements" to ensure certain tasks are only being run if DEV_SITE and/or STAGING_SITE are enabled.

But for now the OP's conflict is resolved.

By the way for any future Googlers, SlickStack will never delete the "staging" or "development" databases under any circumstances to avoid data loss, even if you enabled, but later disabled, those sites.