doc/development/database/migration_squashing.md
{{< history >}}
{{< /history >}}
Migration squashing combines multiple database migrations into a single schema definition to improve database setup performance and maintain a manageable migration history.
Migration squashing is automated through GitLab Housekeeper. The Keeps::SquashMigrations keep creates MRs automatically at scheduled milestones.
The automation runs via a scheduled pipeline job in the Engineering Productivity team's CI configuration.
Squashing occurs at milestones ending in .2, .5, .8, and .11. These align with required stops.
The target branch is two required stops prior to the current milestone:
| Current milestone | Squashes up to |
|---|---|
| X.2 | (X-1).8 |
| X.5 | (X-1).11 |
| X.8 | X.2 |
| X.11 | X.5 |
For example, at the 18.8 required stop, migrations are squashed up to origin/18-2-stable-ee.
To squash migrations manually from a previous version (such as 16.10), run:
bundle exec rake "gitlab:db:squash[origin/16-10-stable-ee]"
This Rake task:
db/init_structure.sql with the squashed schema| Parameter | Description |
|---|---|
[origin/16-10-stable-ee] | The Git reference to use as a baseline for migration squashing. This should be the stable branch of the target version. |
If you encounter errors related to missing schema references, check: