Removes database migrations up to 16-1-stable-ee
What does this MR do and why?
Remove database migrations up to 20230615202511
– until 16-1-stable-ee
.
Follow up from !139940 (merged)
Changes in this MR:
- Delete
db/migrate
anddb/post_migrate
introduced in16-1-stable-ee
up to20230615202511
- Delete related specs
- Move
16-1-stable-ee db/structure.sql
changes toinit_structure.sql
- db:rollback job was updated with the first migration from
16.2 - 20230616082958
NOTE 1
We decided not to rename the 20211202041233_init_schema.rb
file, to avoid problems with migrations
NOTE 2
The following specs were removed:
Spec | Reason |
---|---|
spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb | Removed because constraint "check_0dd5948e38" is now in init_structure.sql |
spec/lib/gitlab/background_migration/migrate_human_user_type_spec.rb | Removed because constraint "check_0dd5948e38" is now in init_structure.sql |
spec/lib/gitlab/background_migration/backfill_admin_mode_scope_for_personal_access_tokens_spec.rb | Removed because constraint "check_b8d60815eb" is now in init_structure.sql |
spec/lib/gitlab/background_migration/cleanup_personal_access_tokens_with_nil_expires_at_spec.rb | constraint "check_b8d60815eb" is now in init_structure.sql |
spec/lib/gitlab/background_migration/mark_duplicate_npm_packages_for_destruction_spec.rb | fails because of idx_packages_on_project_id_name_version_unique_when_npm violation |
How did I perform the squash:
I used the squash script: bundle exec rake gitlab:db:squash\[16-1-stable-ee\]
:
- Compared the diff between
master
and16-1-stable-ee
- Deleted all migrations up to
16-1-stable-ee
version - Copied the
structure.sql
file toinit_structure.sql
(from16-1-stable-ee
version)
How to set up and validate locally
master
branch
Generate a diff file from - Checkout
master
branch
git checkout master
- Re-create the database
gdk stop && gdk start db && bin/rails db:drop db:create
- Migration to version
20230615202511
(last migration from15-9-stable-ee
)
bin/rails db:migrate:main VERSION=20230615202511
- Store
structure.sql
the diff in a temp file
cat db/structure.sql > tmp/master.diff
- Reset the changes
git reset --hard origin
409574-remove-old-migrations-to-16-1
branch
Generate a diff file from - Checkout current branch
git checkout 409574-remove-old-migrations-to-16-1
- Re-create the database
gdk stop && gdk start db && bin/rails db:drop db:create
- Migrate to version
20211202041233
(only the init_schema migration)
bin/rails db:migrate:main VERSION=20211202041233
- Store
structure.sql
the diff in a temp file
cat db/structure.sql > tmp/squash.diff
- Reset the changes
git reset --hard 409574-remove-old-migrations-to-16-1
Check the changes between files
git diff tmp/master.diff tmp/squash.diff
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #409574 (closed)
Edited by Leonardo da Rosa