CodeIgniter Forums
Proper use of migrations in a production project - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Proper use of migrations in a production project (/showthread.php?tid=92749)



Proper use of migrations in a production project - brunoggdev - 04-15-2025

Hello!

I've started working on a CI4 project that is already running for a while now and has a bunch of complex data and db structure but does not uses migrations.

As the documentation itself states: 
Quote:You could edit fragments of SQL by hand but you would then be responsible for telling other developers that they need to go and run them. You would also have to keep track of which changes need to be run against the production machines next time you deploy.

And those are exactly the problems we are having!

That being said, I wanted to know how exactly are you supposed to use migrations in production. Should I configure my deploys to run the command "php spark migrate" automatically? Is it safe? What do you recommend as the correct approach and steps to do it correctly and safely?


RE: Proper use of migrations in a production project - kcs - 04-17-2025

I am also super inter interested in the question Smile
I am a big fan of migrations now that I understood I could also use them for updating db and content, and I very much like the reliability they give me so I can work on changes, then deploy them on my staging environnement and then production without a doubt that the changes in the database will be made as they should. And while I have deployments automatised, I did not yet manage to automatise that part.
Right now I use gitlab CI/CD jobs for deployments, but I still have to go launch the migrations manually.
In my thinking, I considered at least doing a php spark migrate status to warn migrations were needed but I dropped it because I was not managing to get Gitlab to do it (forgot for which reason exactly).