Handling database in a team

What issue or error are you experiencing?

I’m part of a small team working on a website hosted by WP Engine. We all pulled the website locally and created a GitHub repository to work on our plugin and theme files, but we don’t know how to properly handle the database without risking overwriting each others work or breaking everything.

I thought of connecting the local environment to the remote database hosted on WP Engine so that we all basically work on the same database, but I can’t get it to work. Any idea/help?

Hey @giannn - thanks for using Local!

A bit of a two-part answer:

Database best practices - Always pull the database down to Local as needed to update your development environment with the latest data. Never push (or at least, be very careful you understand what the effect will be!) the Local database up to production.

If you need to make database changes that will be reflected in the production site, I’d recommend making those on staging in WP Engine and promote changes to the production database from there.

If you’re testing the site locally and just need database changes to validate your testing, I’d make them locally. When the site is pushed, don’t include the database.

This should let you version the files you care about (plugins and themes) without worrying about breaking the production database.

Workflow Question - Can you expand on “how to properly handle the database without risking overwriting each others work or breaking everything”? Is there an instance where you’d want two machines to have the same copy of a dev database that is significantly different from production?

As for how to do this, Local has a feature called Magic Sync that allows you to pick and choose the files (and database) you wish to include on a push to or pull from WPE. In this case, I would recommend pulling the site from WP Engine, checking the box to include the database and unselecting all files. This will sync the production database with your environment as needed.

Hopefully that is helpful! Let me know if you have questions, I’m happy to answer.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.