For convenience, squash_migrations.sh
script squashes the migrations, but whoever PRs the result is responsible for verifying that the migrations are squashed and LastSquashedMigrationVersion
in db/admin.go
is updated correctly, regardless of the result of having run the script.
Each major release of Apache Traffic Control combines database migrations from previous ATC releases into create_tables.sql
.
For example, suppose the latest version of Apache Traffic Control is 147.5.8 and contains these migrations:
1_my-migration.up.sql
1_my-migration.down.sql
3_another-migration.up.sql
3_another-migration.down.sql
And suppose the ATC master
branch contains these migrations:
1_my-migration.up.sql
1_my-migration.down.sql
3_another-migration.up.sql
3_another-migration.down.sql
4_migration-name.up.sql
4_migration-name.down.sql
9_add-column-to-table.up.sql
9_add-column-to-table.down.sql
In order to prepare database migrations for the next major release, in this case, ATC 148.0.0, migrations 1
and 3
should be collapsed into create_tables.sql
and migrations 4
and 9
should remain in traffic_ops/app/db/migrations/
.
3
is the migration timestamp of the last up/down migration set. Find the definition for LastSquashedMigrationTimestamp
in traffic_ops/app/db/admin.go
and change it to 3
.4
. Find the definition for FirstMigrationTimestamp
in traffic_ops/app/db/admin.go
and change it to 4
.Past PRs that have collapsed the DB migrations: