Commit f54f4c1f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Prepare deployments table for bigint conversion

Adds bigint column and triggers to prepare for bigint conversion

Changelog: other
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62459
parent edaad05e
...@@ -8,6 +8,9 @@ class Deployment < ApplicationRecord ...@@ -8,6 +8,9 @@ class Deployment < ApplicationRecord
include Importable include Importable
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
include FastDestroyAll include FastDestroyAll
include IgnorableColumns
ignore_column :deployable_id_convert_to_bigint, remove_with: '14.2', remove_after: '2021-08-22'
belongs_to :project, required: true belongs_to :project, required: true
belongs_to :environment, required: true belongs_to :environment, required: true
......
# frozen_string_literal: true
class InitializeConversionOfDeploymentsToBigint < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
TABLE = :deployments
COLUMNS = %i(deployable_id)
def up
initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
def down
revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
end
# frozen_string_literal: true
class BackfillDeploymentsForBigintConversion < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
TABLE = :deployments
COLUMNS = %i(deployable_id)
def up
backfill_conversion_of_integer_to_bigint TABLE, COLUMNS
end
def down
revert_backfill_conversion_of_integer_to_bigint TABLE, COLUMNS
end
end
a2ce644df46a13d65eb0d01931eeb8e9f43967daadf73eed2f033b6c275ca57d
\ No newline at end of file
f085c9a7fc2209cf4d3797cda55c2be76b462eff456e7bf92de4545e0b988053
\ No newline at end of file
...@@ -143,6 +143,15 @@ BEGIN ...@@ -143,6 +143,15 @@ BEGIN
END; END;
$$; $$;
CREATE FUNCTION trigger_77f5e1d20482() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW."deployable_id_convert_to_bigint" := NEW."deployable_id";
RETURN NEW;
END;
$$;
CREATE FUNCTION trigger_8485e97c00e3() RETURNS trigger CREATE FUNCTION trigger_8485e97c00e3() RETURNS trigger
LANGUAGE plpgsql LANGUAGE plpgsql
AS $$ AS $$
...@@ -12288,7 +12297,8 @@ CREATE TABLE deployments ( ...@@ -12288,7 +12297,8 @@ CREATE TABLE deployments (
on_stop character varying, on_stop character varying,
status smallint NOT NULL, status smallint NOT NULL,
finished_at timestamp with time zone, finished_at timestamp with time zone,
cluster_id integer cluster_id integer,
deployable_id_convert_to_bigint bigint
); );
CREATE SEQUENCE deployments_id_seq CREATE SEQUENCE deployments_id_seq
...@@ -25277,6 +25287,8 @@ CREATE TRIGGER trigger_51ab7cef8934 BEFORE INSERT OR UPDATE ON ci_builds_runner_ ...@@ -25277,6 +25287,8 @@ CREATE TRIGGER trigger_51ab7cef8934 BEFORE INSERT OR UPDATE ON ci_builds_runner_
CREATE TRIGGER trigger_69523443cc10 BEFORE INSERT OR UPDATE ON events FOR EACH ROW EXECUTE FUNCTION trigger_69523443cc10(); CREATE TRIGGER trigger_69523443cc10 BEFORE INSERT OR UPDATE ON events FOR EACH ROW EXECUTE FUNCTION trigger_69523443cc10();
CREATE TRIGGER trigger_77f5e1d20482 BEFORE INSERT OR UPDATE ON deployments FOR EACH ROW EXECUTE FUNCTION trigger_77f5e1d20482();
CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_8485e97c00e3(); CREATE TRIGGER trigger_8485e97c00e3 BEFORE INSERT OR UPDATE ON ci_sources_pipelines FOR EACH ROW EXECUTE FUNCTION trigger_8485e97c00e3();
CREATE TRIGGER trigger_8487d4de3e7b BEFORE INSERT OR UPDATE ON ci_builds_metadata FOR EACH ROW EXECUTE FUNCTION trigger_8487d4de3e7b(); CREATE TRIGGER trigger_8487d4de3e7b BEFORE INSERT OR UPDATE ON ci_builds_metadata FOR EACH ROW EXECUTE FUNCTION trigger_8487d4de3e7b();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment