Add default values for file store columns

The lfs_objects, ci_job_artifacts, and uploads table does
not have a default value for the file store columns. To
avoid the madness of three-state booleans where it can be
true, false, or NULL we are setting a default value for
these records.
parent bac995be
# frozen_string_literal: true
class AddDefaultValueForFileStoreToLfsObjects < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
change_column_default :lfs_objects, :file_store, 1
end
end
def down
with_lock_retries do
change_column_default :lfs_objects, :file_store, nil
end
end
end
# frozen_string_literal: true
class AddDefaultValueForFileStoreToCiJobArtifacts < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
change_column_default :ci_job_artifacts, :file_store, 1
end
end
def down
with_lock_retries do
change_column_default :ci_job_artifacts, :file_store, nil
end
end
end
# frozen_string_literal: true
class AddDefaultValueForStoreToUploads < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
change_column_default :uploads, :store, 1
end
end
def down
with_lock_retries do
change_column_default :uploads, :store, nil
end
end
end
......@@ -1120,7 +1120,7 @@ CREATE TABLE public.ci_job_artifacts (
updated_at timestamp with time zone NOT NULL,
expire_at timestamp with time zone,
file character varying,
file_store integer,
file_store integer DEFAULT 1,
file_sha256 bytea,
file_format smallint,
file_location smallint,
......@@ -3644,7 +3644,7 @@ CREATE TABLE public.lfs_objects (
created_at timestamp without time zone,
updated_at timestamp without time zone,
file character varying,
file_store integer
file_store integer DEFAULT 1
);
CREATE SEQUENCE public.lfs_objects_id_seq
......@@ -6487,7 +6487,7 @@ CREATE TABLE public.uploads (
model_type character varying,
uploader character varying NOT NULL,
created_at timestamp without time zone NOT NULL,
store integer,
store integer DEFAULT 1,
mount_point character varying,
secret character varying
);
......@@ -13706,5 +13706,8 @@ COPY "schema_migrations" (version) FROM STDIN;
20200424101920
20200427064130
20200429015603
20200429181335
20200429181955
20200429182245
\.
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