Answer the question
In order to leave comments, you need to log in
How to properly implement continuous deployment to run migrations?
We have an online store.
We work through git (repo on gitlab).
Now, when developing new features, we manually go to the store server and do a git pull with a new feature.
It often happens that along with the codebase, you need to run some kind of migration script (or other script) as part of the current, new feature.
Now, at the root of the project, we have a directory where the migration files are placed.
What kind of migration, what feature it belongs to, we understand ourselves.
And after deploying the code to production, we manually run the migration script that applies to the new feature.
Can you please tell me how this can be automated through continuous deployment (for example, through gitlab)?
And most importantly, it is not clear where and how to store migration files so that during automatic deployment it can be determined if the current feature has its own migration files or other scripts needed to run?
Answer the question
In order to leave comments, you need to log in
Well, everything is done by hand.
Make a directory for migration files and in it some main control.sh type
in
control.sh include the actual migration files
And that's it. When auto-deploying a specific version, in its branch it will find a list of migration scripts in control.sh, control.sh can check through the database whether they should be run or skipped if they have already been completed, or executed regardless of this and make a record in the database about the execution .
Naturally, control is the responsibility of the developers, there will be no magic here. And it is assumed that you always deploy a later version on top of the old one.
Don't reinvent the wheel.
There is a ready-made tool for Flyway migrations - it couldn't be easier.
Agree with BorLaze - use something ready made. For example https://www.liquibase.org/ .
correctly implement continuous deployment to run migrationsthrough pre-backup. Anything happened
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question