Add post migration step for removing null pages_domain
What does this MR do and why?
Add post migration step for removing null pages_domain
Local migration logs
➜ gitlab git:(master) ✗ bin/rails db:migrate RAILS_ENV=development
main: == [advisory_lock_connection] object_id: 128800, pg_backend_pid: 34997
main: == 20240916084832 DeleteInvalidPagesDomainsRecords: migrating =================
main: == 20240916084832 DeleteInvalidPagesDomainsRecords: migrated (0.0400s) ========
main: == [advisory_lock_connection] object_id: 128800, pg_backend_pid: 34997
ci: == [advisory_lock_connection] object_id: 129040, pg_backend_pid: 34999
ci: == 20240916084832 DeleteInvalidPagesDomainsRecords: migrating =================
ci: -- The migration is skipped since it modifies the schemas: [:gitlab_main].
ci: -- This database can only apply migrations in one of the following schemas: [:gitlab_ci, :gitlab_internal, :gitlab_shared].
ci: == 20240916084832 DeleteInvalidPagesDomainsRecords: migrated (0.0073s) ========
ci: == [advisory_lock_connection] object_id: 129040, pg_backend_pid: 34999
➜ gitlab git:(master) ✗ bin/rails db:migrate RAILS_ENV=development
main: == [advisory_lock_connection] object_id: 128800, pg_backend_pid: 36099
main: == 20240916091255 AddNotNullConstraintToPagesDomainProjectId: migrating =======
main: -- current_schema(nil)
main: -> 0.0012s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("ALTER TABLE pages_domains\nADD CONSTRAINT check_790fbb64fa\nCHECK ( project_id IS NOT NULL )\nNOT VALID;\n")
main: -> 0.0016s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0003s
main: -- execute("ALTER TABLE pages_domains VALIDATE CONSTRAINT check_790fbb64fa;")
main: -> 0.0006s
main: -- execute("RESET statement_timeout")
main: -> 0.0003s
main: == 20240916091255 AddNotNullConstraintToPagesDomainProjectId: migrated (0.0390s)
main: == [advisory_lock_connection] object_id: 128800, pg_backend_pid: 36099
ci: == [advisory_lock_connection] object_id: 129060, pg_backend_pid: 36101
ci: == 20240916091255 AddNotNullConstraintToPagesDomainProjectId: migrating =======
ci: -- current_schema(nil)
ci: -> 0.0002s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- transaction_open?(nil)
ci: -> 0.0000s
ci: -- execute("ALTER TABLE pages_domains\nADD CONSTRAINT check_790fbb64fa\nCHECK ( project_id IS NOT NULL )\nNOT VALID;\n")
ci: -> 0.0018s
ci: -- execute("SET statement_timeout TO 0")
ci: -> 0.0003s
ci: -- execute("ALTER TABLE pages_domains VALIDATE CONSTRAINT check_790fbb64fa;")
ci: -> 0.0008s
ci: -- execute("RESET statement_timeout")
ci: -> 0.0003s
ci: == 20240916091255 AddNotNullConstraintToPagesDomainProjectId: migrated (0.0202s)
ci: == [advisory_lock_connection] object_id: 129060, pg_backend_pid: 36101
Related: #442178 (closed)
Changelog: changed
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Edited by Naman Jagdish Gala