Backfill primary key migration for self-managed instances
What does this MR do?
This MR is the last step from #329511 (closed) and starts backfilling PK conversion for self-managed instances.
Database migrations
Up
$ bundle exec rails db:migrate:up VERSION=20210520012430
== 20210520012430 BackfillPkConversionForSelfManaged: migrating ===============
-- table_exists?(:events)
-> 0.0013s
-- column_exists?(:events, :id)
-> 0.0010s
-- column_exists?(:events, :id)
-> 0.0008s
-- column_exists?(:events, "id_convert_to_bigint")
-> 0.0008s
unknown OID 28: failed to recognize type of 'relfrozenxid'. It will be treated as String.
unknown OID 1034: failed to recognize type of 'relacl'. It will be treated as String.
unknown OID 194: failed to recognize type of 'relpartbound'. It will be treated as String.
-- table_exists?(:push_event_payloads)
-> 0.0003s
-- column_exists?(:push_event_payloads, :event_id)
-> 0.0009s
-- column_exists?(:push_event_payloads, :event_id)
-> 0.0008s
-- column_exists?(:push_event_payloads, "event_id_convert_to_bigint")
-> 0.0008s
-- table_exists?(:ci_job_artifacts)
-> 0.0004s
-- column_exists?(:ci_job_artifacts, :id)
-> 0.0012s
-- column_exists?(:ci_job_artifacts, :id)
-> 0.0009s
-- column_exists?(:ci_job_artifacts, "id_convert_to_bigint")
-> 0.0008s
-- column_exists?(:ci_job_artifacts, :job_id)
-> 0.0009s
-- column_exists?(:ci_job_artifacts, "job_id_convert_to_bigint")
-> 0.0008s
-- table_exists?(:ci_sources_pipelines)
-> 0.0004s
-- column_exists?(:ci_sources_pipelines, :id)
-> 0.0009s
-- column_exists?(:ci_sources_pipelines, :source_job_id)
-> 0.0008s
-- column_exists?(:ci_sources_pipelines, "source_job_id_convert_to_bigint")
-> 0.0007s
-- table_exists?(:ci_build_needs)
-> 0.0003s
-- column_exists?(:ci_build_needs, :id)
-> 0.0026s
-- column_exists?(:ci_build_needs, :build_id)
-> 0.0010s
-- column_exists?(:ci_build_needs, "build_id_convert_to_bigint")
-> 0.0008s
-- table_exists?(:ci_builds)
-> 0.0004s
-- column_exists?(:ci_builds, :id)
-> 0.0016s
-- column_exists?(:ci_builds, :id)
-> 0.0014s
-- column_exists?(:ci_builds, "id_convert_to_bigint")
-> 0.0015s
-- column_exists?(:ci_builds, :stage_id)
-> 0.0014s
-- column_exists?(:ci_builds, "stage_id_convert_to_bigint")
-> 0.0014s
-- table_exists?(:ci_builds_runner_session)
-> 0.0003s
-- column_exists?(:ci_builds_runner_session, :id)
-> 0.0008s
-- column_exists?(:ci_builds_runner_session, :build_id)
-> 0.0008s
-- column_exists?(:ci_builds_runner_session, "build_id_convert_to_bigint")
-> 0.0007s
-- table_exists?(:ci_build_trace_chunks)
-> 0.0004s
-- column_exists?(:ci_build_trace_chunks, :id)
-> 0.0009s
-- column_exists?(:ci_build_trace_chunks, :build_id)
-> 0.0008s
-- column_exists?(:ci_build_trace_chunks, "build_id_convert_to_bigint")
-> 0.0008s
== 20210520012430 BackfillPkConversionForSelfManaged: migrated (0.1657s) ======
Down
$ bundle exec rails db:migrate:down VERSION=20210520012430
== 20210520012430 BackfillPkConversionForSelfManaged: reverting ===============
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'events' AND column_name = 'id' AND job_arguments = '[[\"id\"],[\"id_convert_to_bigint\"]]'")
-> 0.0022s
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'push_event_payloads' AND column_name = 'event_id' AND job_arguments = '[[\"event_id\"],[\"event_id_convert_to_bigint\"]]'")
-> 0.0006s
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'ci_job_artifacts' AND column_name = 'id' AND job_arguments = '[[\"id\",\"job_id\"],[\"id_convert_to_bigint\",\"job_id_convert_to_bigint\"]]'")
-> 0.0006s
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'ci_sources_pipelines' AND column_name = 'id' AND job_arguments = '[[\"source_job_id\"],[\"source_job_id_convert_to_bigint\"]]'")
-> 0.0006s
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'ci_build_needs' AND column_name = 'id' AND job_arguments = '[[\"build_id\"],[\"build_id_convert_to_bigint\"]]'")
-> 0.0006s
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'ci_builds' AND column_name = 'id' AND job_arguments = '[[\"id\",\"stage_id\"],[\"id_convert_to_bigint\",\"stage_id_convert_to_bigint\"]]'")
-> 0.0006s
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'ci_builds_runner_session' AND column_name = 'id' AND job_arguments = '[[\"build_id\"],[\"build_id_convert_to_bigint\"]]'")
-> 0.0005s
-- execute("DELETE FROM batched_background_migrations WHERE job_class_name = 'CopyColumnUsingBackgroundMigrationJob' AND table_name = 'ci_build_trace_chunks' AND column_name = 'id' AND job_arguments = '[[\"build_id\"],[\"build_id_convert_to_bigint\"]]'")
-> 0.0006s
== 20210520012430 BackfillPkConversionForSelfManaged: reverted (0.0070s) ======
Does this MR meet the acceptance criteria?
Conformity
-
I have included a changelog entry, or it's not needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Security
Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #329511 (closed)
Edited by Krasimir Angelov