Skip to content

Removes database migrations up to 15-9-stable-ee

What does this MR do and why?

Remove database migrations up to 2023021‎6054348‎ – until 15-9-stable-ee.

Follow up from !137701 (merged)

Changes in this MR:

  • Delete db/migrate introduced in 15-9-stable-ee up to 20230214142813
  • Delete db/post_migrate introduced in 15-9-stable-ee up to 20230216054348
  • Delete related specs
  • Move 15-9-stable-ee db/structure.sql changes to init_structure.sql
NOTE 1

We decided not to rename the 20211202041233_init_schema.rb file, to avoid problems with migrations

NOTE 2

You will notice that I didn't remove some migrations that have the timestamp before 2023021‎6054348‎. This is because these migrations were introduced in another release (like 16-XX-stable-ee).

NOTE 3

The following specs were removed:

Spec Reason
spec/lib/gitlab/background_migration/backfill_imported_issue_search_data_spec.rb Removed because a constraint check was added
spec/lib/gitlab/background_migration/backfill_project_namespace_on_issues_spec.rb Removed because a constraint check was added
spec/lib/gitlab/background_migration/backfill_user_details_fields_spec.rb Linkedin field was moved to user-details in init schema
spec/lib/gitlab/background_migration/backfill_work_item_type_id_for_issues_spec.rb Removed because a constraint check was added
spec/lib/gitlab/background_migration/disable_legacy_open_source_license_for_no_issues_no_repo_projects_spec.rb Removed because a constraint check was added
spec/lib/gitlab/background_migration/expire_o_auth_tokens_spec.rb Removed because a constraint check was added
spec/lib/gitlab/background_migration/remove_project_group_link_with_missing_groups_spec.rb Removed because migration that fixed the records was moved to init_structure.sql
NOTE 4

I have to fix the spec/fixtures/migrations/db/migrate/schema_cache_migration_test.rb spec, as It's using a migration that was removed in this squash

How did I perform the squash:

I used the squash script: bundle exec rake gitlab:db:squash\[15-9-stable-ee\]:

  • Compared the diff between master and 15-9-stable-ee
  • Deleted all migrations up to 15-9-stable-ee version
  • Copied the structure.sql file to init_structure.sql (from 15-9-stable-ee version)

How to set up and validate locally

Generate a diff file from master branch

  1. Checkout master branch
git checkout master
  1. Re-create the database
gdk stop && gdk start db && bin/rails db:drop db:create
  1. Migration to version 2023021‎6054348‎ (last migration from 15-9-stable-ee)
bin/rails db:migrate:main VERSION=20230216054348
  1. Store structure.sql the diff in a temp file
cat db/structure.sql > tmp/master.diff
  1. Reset the changes
git reset --hard origin

Generate a diff file from 409574-remove-old-migrations-before-20220824082427-15-9 branch

  1. Checkout current branch
git checkout 409574-remove-old-migrations-before-20220824082427-15-9
  1. Re-create the database
gdk stop && gdk start db && bin/rails db:drop db:create
  1. Migrate to version 20211202041233 (only the init_schema migration)
bin/rails db:migrate:main VERSION=20211202041233
  1. Store structure.sql the diff in a temp file
cat db/structure.sql > tmp/squash.diff
  1. Reset the changes
git reset --hard 409574-remove-old-migrations-before-20220824082427-15-9

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.

Related to #409574 (closed)

Edited by Leonardo da Rosa

Merge request reports