Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-30 21:10:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-30 21:10:11 +0300
commitc51425915fb1b2c367d6d828449b5cc7772ac104 (patch)
treee0bb2d9f3e0c9aaec6fe71a9da26f9bab5d9890c /db
parentf65227a163435d66e3f0b80f4c52ae59d8df39a2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20231025025733_swap_columns_for_ci_pipelines_pipeline_id_bigint_for_self_host.rb54
-rw-r--r--db/schema_migrations/202310250257331
2 files changed, 55 insertions, 0 deletions
diff --git a/db/post_migrate/20231025025733_swap_columns_for_ci_pipelines_pipeline_id_bigint_for_self_host.rb b/db/post_migrate/20231025025733_swap_columns_for_ci_pipelines_pipeline_id_bigint_for_self_host.rb
new file mode 100644
index 00000000000..a960258ff3d
--- /dev/null
+++ b/db/post_migrate/20231025025733_swap_columns_for_ci_pipelines_pipeline_id_bigint_for_self_host.rb
@@ -0,0 +1,54 @@
+# frozen_string_literal: true
+
+class SwapColumnsForCiPipelinesPipelineIdBigintForSelfHost < Gitlab::Database::Migration[2.2]
+ include Gitlab::Database::MigrationHelpers::Swapping
+
+ milestone '16.6'
+ disable_ddl_transaction!
+
+ TABLE_NAME = :ci_pipelines
+ TRIGGER_FUNCTION_NAME = :trigger_1bd97da9c1a4
+ COLUMN_NAME = :auto_canceled_by_id
+ BIGINT_COLUMN_NAME = :auto_canceled_by_id_convert_to_bigint
+ FK_NAME = :fk_262d4c2d19
+ BIGINT_FK_NAME = :fk_67e4288f3a
+ INDEX_NAME = :index_ci_pipelines_on_auto_canceled_by_id
+ BIGINT_INDEX_NAME = :index_ci_pipelines_on_auto_canceled_by_id_bigint
+
+ def up
+ return if column_type_of?(:bigint)
+
+ swap
+ end
+
+ def down
+ return if column_type_of?(:integer)
+
+ swap
+ end
+
+ private
+
+ def column_type_of?(type)
+ column_for(TABLE_NAME, COLUMN_NAME).sql_type.to_s == type.to_s
+ end
+
+ def swap
+ with_lock_retries(raise_on_exhaustion: true) do
+ # Lock the tables involved.
+ lock_tables(TABLE_NAME)
+
+ # Rename the columns to swap names
+ swap_columns(TABLE_NAME, COLUMN_NAME, BIGINT_COLUMN_NAME)
+
+ # Reset the trigger function
+ reset_trigger_function(TRIGGER_FUNCTION_NAME)
+
+ # Swap fkey constraint
+ swap_foreign_keys(TABLE_NAME, FK_NAME, BIGINT_FK_NAME)
+
+ # Swap index
+ swap_indexes(TABLE_NAME, INDEX_NAME, BIGINT_INDEX_NAME)
+ end
+ end
+end
diff --git a/db/schema_migrations/20231025025733 b/db/schema_migrations/20231025025733
new file mode 100644
index 00000000000..a488c5206e1
--- /dev/null
+++ b/db/schema_migrations/20231025025733
@@ -0,0 +1 @@
+c0129899dcea5f304661b49665a371de86dbff9df88afbb3fdbb348a411c1dd8 \ No newline at end of file