Commit 87577077 authored by Toon Claes's avatar Toon Claes

Merge branch '218004-validate-the-not-null-constraint-on-file-store-columns' into 'master'

Validate the 'NOT NULL' constraint on file store columns

Closes #218004

See merge request gitlab-org/gitlab!34568
parents 7cae7a47 bf213bea
---
title: Validate the existing not null constraints on columns for ci_job_artifacts, lfs_objects, and uploads tables.
merge_request: 34568
author:
type: other
# frozen_string_literal: true
class CleanUpFileStoreLfsObjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# rubocop:disable Migration/UpdateColumnInBatches
update_column_in_batches(:lfs_objects, :file_store, 1) do |table, query|
query.where(table[:file_store].eq(nil))
end
# rubocop:enable Migration/UpdateColumnInBatches
end
def down
# no-op
end
end
# frozen_string_literal: true
class CleanUpStoreUploads < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# rubocop:disable Migration/UpdateColumnInBatches
update_column_in_batches(:uploads, :store, 1) do |table, query|
query.where(table[:store].eq(nil))
end
# rubocop:enable Migration/UpdateColumnInBatches
end
def down
# no-op
end
end
# frozen_string_literal: true
class CleanUpFileStoreCiJobArtifacts < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
# rubocop:disable Migration/UpdateColumnInBatches
# rubocop:disable Migration/UpdateLargeTable
update_column_in_batches(:ci_job_artifacts, :file_store, 1) do |table, query|
query.where(table[:file_store].eq(nil))
end
# rubocop:enable Migration/UpdateColumnInBatches
# rubocop:enable Migration/UpdateLargeTable
end
def down
# no-op
end
end
# frozen_string_literal: true
class ValidateFileStoreNotNullConstraintOnLfsObjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
validate_check_constraint(:lfs_objects, :check_eecfc5717d)
end
def down
# no-op
end
end
# frozen_string_literal: true
class ValidateStoreNotNullConstraintUploads < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
validate_check_constraint(:uploads, :check_5e9547379c)
end
def down
# no-op
end
end
# frozen_string_literal: true
class ValidateFileStoreNotNullConstraintOnCiJobArtifacts < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
validate_check_constraint(:ci_job_artifacts, :check_27f0f6dbab)
end
def down
# no-op
end
end
......@@ -1227,7 +1227,8 @@ CREATE TABLE public.ci_job_artifacts (
file_sha256 bytea,
file_format smallint,
file_location smallint,
locked boolean
locked boolean,
CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL))
);
CREATE SEQUENCE public.ci_job_artifacts_id_seq
......@@ -3801,7 +3802,8 @@ CREATE TABLE public.lfs_objects (
created_at timestamp without time zone,
updated_at timestamp without time zone,
file character varying,
file_store integer DEFAULT 1
file_store integer DEFAULT 1,
CONSTRAINT check_eecfc5717d CHECK ((file_store IS NOT NULL))
);
CREATE SEQUENCE public.lfs_objects_id_seq
......@@ -6736,7 +6738,8 @@ CREATE TABLE public.uploads (
created_at timestamp without time zone NOT NULL,
store integer DEFAULT 1,
mount_point character varying,
secret character varying
secret character varying,
CONSTRAINT check_5e9547379c CHECK ((store IS NOT NULL))
);
CREATE SEQUENCE public.uploads_id_seq
......@@ -8261,15 +8264,6 @@ ALTER TABLE ONLY public.chat_teams
ALTER TABLE public.design_management_designs
ADD CONSTRAINT check_07155e2715 CHECK ((char_length((filename)::text) <= 255)) NOT VALID;
ALTER TABLE public.ci_job_artifacts
ADD CONSTRAINT check_27f0f6dbab CHECK ((file_store IS NOT NULL)) NOT VALID;
ALTER TABLE public.uploads
ADD CONSTRAINT check_5e9547379c CHECK ((store IS NOT NULL)) NOT VALID;
ALTER TABLE public.lfs_objects
ADD CONSTRAINT check_eecfc5717d CHECK ((file_store IS NOT NULL)) NOT VALID;
ALTER TABLE ONLY public.ci_build_needs
ADD CONSTRAINT ci_build_needs_pkey PRIMARY KEY (id);
......@@ -14080,5 +14074,11 @@ COPY "schema_migrations" (version) FROM STDIN;
20200615121217
20200615123055
20200615232735
20200617000757
20200617001001
20200617001118
20200617001637
20200617001848
20200617002030
\.
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