diff --git a/db/migrate/20230809165212_add_path_prefix_and_build_ref_to_pages_deployments.rb b/db/migrate/20230809165212_add_path_prefix_and_build_ref_to_pages_deployments.rb new file mode 100644 index 0000000000000000000000000000000000000000..d2fc8bfc9bca1df217ef6a6690377434fce9fd1d --- /dev/null +++ b/db/migrate/20230809165212_add_path_prefix_and_build_ref_to_pages_deployments.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddPathPrefixAndBuildRefToPagesDeployments < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + # rubocop:disable Migration/AddLimitToTextColumns + # limit is added in 20230809165213_add_index_to_path_prefix_and_ref_to_pages_deployments + def change + add_column :pages_deployments, :path_prefix, :text + add_column :pages_deployments, :build_ref, :text + end + # rubocop:enable Migration/AddLimitToTextColumns +end diff --git a/db/migrate/20230809165213_add_index_to_path_prefix_and_build_ref_to_pages_deployments.rb b/db/migrate/20230809165213_add_index_to_path_prefix_and_build_ref_to_pages_deployments.rb new file mode 100644 index 0000000000000000000000000000000000000000..bea4346cfab942f705fdffbd441913f51e7d48ea --- /dev/null +++ b/db/migrate/20230809165213_add_index_to_path_prefix_and_build_ref_to_pages_deployments.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class AddIndexToPathPrefixAndBuildRefToPagesDeployments < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + TABLE_NAME = :pages_deployments + INDEX_NAME = 'index_pages_deployments_unique_path_prefix_by_project' + + def up + add_text_limit TABLE_NAME, :path_prefix, 128 + add_text_limit TABLE_NAME, :build_ref, 512 + + add_concurrent_index TABLE_NAME, + [:project_id, :path_prefix], + name: INDEX_NAME, + unique: true + end + + def down + remove_text_limit TABLE_NAME, :path_prefix + remove_text_limit TABLE_NAME, :build_ref + + remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME + end +end diff --git a/db/schema_migrations/20230809165212 b/db/schema_migrations/20230809165212 new file mode 100644 index 0000000000000000000000000000000000000000..72d1751c42ef9bd1942b77f41edb0e0e657c3023 --- /dev/null +++ b/db/schema_migrations/20230809165212 @@ -0,0 +1 @@ +4137f5af1cb4a00144afecac7ad99e926be4f5a8fa501faaab00f4f017c90cf6 \ No newline at end of file diff --git a/db/schema_migrations/20230809165213 b/db/schema_migrations/20230809165213 new file mode 100644 index 0000000000000000000000000000000000000000..c0bcff0566ed6ae55556fd8f40355b8b91006d58 --- /dev/null +++ b/db/schema_migrations/20230809165213 @@ -0,0 +1 @@ +cdab5ff65d93b1883bd75c60efa21ce03031b2678f4535ae2a50a6ca4377c32d \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 8d694c00c6c72d88be712816998e5c68da33cf4b..9cf19843a4fa0acbb328cf54e7c194b152fa01be 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -20244,8 +20244,12 @@ CREATE TABLE pages_deployments ( file_sha256 bytea NOT NULL, size bigint, root_directory text DEFAULT 'public'::text, + path_prefix text, + build_ref text, + CONSTRAINT check_4d04b8dc9a CHECK ((char_length(path_prefix) <= 128)), CONSTRAINT check_5f9132a958 CHECK ((size IS NOT NULL)), CONSTRAINT check_7e938c810a CHECK ((char_length(root_directory) <= 255)), + CONSTRAINT check_b44e900e5c CHECK ((char_length(build_ref) <= 512)), CONSTRAINT check_f0fe8032dd CHECK ((char_length(file) <= 255)) ); @@ -32701,6 +32705,8 @@ CREATE INDEX index_pages_deployments_on_file_store_and_id ON pages_deployments U CREATE INDEX index_pages_deployments_on_project_id ON pages_deployments USING btree (project_id); +CREATE UNIQUE INDEX index_pages_deployments_unique_path_prefix_by_project ON pages_deployments USING btree (project_id, path_prefix); + CREATE INDEX index_pages_domain_acme_orders_on_challenge_token ON pages_domain_acme_orders USING btree (challenge_token); CREATE INDEX index_pages_domain_acme_orders_on_pages_domain_id ON pages_domain_acme_orders USING btree (pages_domain_id);