Validate the 'NOT NULL' constraint on file store columns

Clean up the data with data migration and
validate the NOT NULL constraints.
parent da918859
# 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
...@@ -1221,7 +1221,8 @@ CREATE TABLE public.ci_job_artifacts ( ...@@ -1221,7 +1221,8 @@ CREATE TABLE public.ci_job_artifacts (
file_sha256 bytea, file_sha256 bytea,
file_format smallint, file_format smallint,
file_location 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 CREATE SEQUENCE public.ci_job_artifacts_id_seq
...@@ -3774,7 +3775,8 @@ CREATE TABLE public.lfs_objects ( ...@@ -3774,7 +3775,8 @@ CREATE TABLE public.lfs_objects (
created_at timestamp without time zone, created_at timestamp without time zone,
updated_at timestamp without time zone, updated_at timestamp without time zone,
file character varying, 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 CREATE SEQUENCE public.lfs_objects_id_seq
...@@ -6708,7 +6710,8 @@ CREATE TABLE public.uploads ( ...@@ -6708,7 +6710,8 @@ CREATE TABLE public.uploads (
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,
store integer DEFAULT 1, store integer DEFAULT 1,
mount_point character varying, mount_point character varying,
secret character varying secret character varying,
CONSTRAINT check_5e9547379c CHECK ((store IS NOT NULL))
); );
CREATE SEQUENCE public.uploads_id_seq CREATE SEQUENCE public.uploads_id_seq
...@@ -8205,15 +8208,6 @@ ALTER TABLE ONLY public.chat_teams ...@@ -8205,15 +8208,6 @@ ALTER TABLE ONLY public.chat_teams
ALTER TABLE public.design_management_designs ALTER TABLE public.design_management_designs
ADD CONSTRAINT check_07155e2715 CHECK ((char_length((filename)::text) <= 255)) NOT VALID; 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 ALTER TABLE ONLY public.ci_build_needs
ADD CONSTRAINT ci_build_needs_pkey PRIMARY KEY (id); ADD CONSTRAINT ci_build_needs_pkey PRIMARY KEY (id);
...@@ -13998,5 +13992,11 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -13998,5 +13992,11 @@ COPY "schema_migrations" (version) FROM STDIN;
20200615121217 20200615121217
20200615123055 20200615123055
20200615232735 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