doc/development/database/migration_ordering.md
Starting with GitLab 17.1, migrations are executed using a custom ordering scheme that conforms to the GitLab release cadence. This change simplifies the upgrade process, and eases both maintenance and support.
Migrations are executed in an order based upon the 14-digit timestamp given in the file name of the migration itself. This behavior is the default for a Rails application.
GitLab also features logic to extend standard migration behavior in these important ways:
db/post_migrate folder and the db/migrate folder, which
you need when using Post-Deployment migrations.SKIP_POST_DEPLOYMENT_MIGRATIONS, migrations
are not loaded from any post_migrate folder.Migrations are executed in the following order:
milestone defined are executed first, ordered by their timestamp.milestone defined are executed in milestone order:
Example:
milestone defined.17.1 regular migrations.17.1 post-deployment migrations.17.2 regular migrations.17.2 post-deployment migrations.This change causes post-deployment migrations to always be sorted at the end
of a given milestone. Previously, post-deployment migrations were
interleaved with regular ones, provided SKIP_POST_DEPLOYMENT_MIGRATIONS was not set.
When SKIP_POST_DEPLOYMENT_MIGRATIONS is set, post-deployment migrations are not executed.