Docker - how do you deploy with new DB structural updates?

I’ve pushed my docker to Production and it is running live, but now need to publish a change involving the database.

When I follow these fantastic instructions, everything works except my “backed up” live database contents are not restored. I didn’t delete the tables/columns they were in, I just added more tables and columns in the new update, as well as included some base data for the new deploy.

I’m thinking the combo of me wanting to add data, update the structure, AND keep the old data is my issue.

When I deploy again, how do I keep the existing live data while updating the DB with new structure at the same time? If it is a manual process, any pointers would be appreciated.

PS - Thanks to this fantastic community, and especially from the ever-helpful @ Apple, I have been having great success with Docker in Wappler. Much smoother than trying to get everything working with a local dev environment for me!

You learned that trick from me!

With your “Production” target selected (not “Development”) click “Deploy”, and then go the Database manager → Changes → Right-click and click “Apply latest changes”. This last step will apply structure changes (“migrations”). Each migration is a (JavaScript) file that details what changes occurred (e.g.: created table xyz, created column abc). Data additions are not part of migrations! A migration only deletes data if you have a drop table or drop column instruction. There’s something called a “Seed” that’s used to pre-populate a database with data (like a migration but for data), but for a beginner I wouldn’t suggest to use it before you understand the database manager/migrations.

It’s important to realize the data you add on localhost is not added to the remote server - that is, when the Development target is selected. If you want to see data on the remote host, ensure the Production target is selected, and re-create the data if needed. Such data will persist across migration applies, unless the migration itself deletes the table or column in question.

If you’re unable to solve the problem reading the explanations I gave, you’ll need to post screenshots of the steps you’re doing :slight_smile:

1 Like

Haha, yep! I learned so many things from you already – thanks for even more help on this thread :slight_smile:

How funny that it is basically the same solution here as with my DB setup wuestion. I really missed the “Apply latest changes” step in all the tutorials!

THANK YOU for explaining this so clearly. It makes sense now!

This seems simple now that you explain it – you have really given me a great deal of insight on how to use Wappler. Thank you!

2 Likes