Commit ff29fcb0 authored by Yannis Roussos's avatar Yannis Roussos

Merge branch '245304-reference-pages_deployments-in-pages_metadata' into 'master'

Reference pages_deployments in pages_metadata

Closes #245304

See merge request gitlab-org/gitlab!42834
parents 9748207a e932ca25
---
title: Reference pages_deployments in pages_metadata
merge_request: 42834
author:
type: added
# frozen_string_literal: true
class AddPagesDeploymentIdToPagesMetadata < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :project_pages_metadata, :pages_deployment_id, :bigint
end
end
# frozen_string_literal: true
class AddForeignKeyToPagesDeploymentIdInProjectPagesMetadata < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_project_pages_metadata_on_pages_deployment_id'
disable_ddl_transaction!
def up
add_concurrent_index(:project_pages_metadata, :pages_deployment_id, name: INDEX_NAME)
add_concurrent_foreign_key :project_pages_metadata, :pages_deployments, column: :pages_deployment_id, on_delete: :nullify
end
def down
remove_foreign_key_if_exists :project_pages_metadata, column: :pages_deployment_id
remove_concurrent_index_by_name(:project_pages_metadata, INDEX_NAME)
end
end
60835078e0a0bd191e9b1f0316f894c5223d6849277992b5034ed4ff9a798fe4
\ No newline at end of file
e4f9e918c86705409555cde065f30ba0c0c405dfd1918f47a169a5dc5c244a8d
\ No newline at end of file
......@@ -14712,7 +14712,8 @@ ALTER SEQUENCE project_mirror_data_id_seq OWNED BY project_mirror_data.id;
CREATE TABLE project_pages_metadata (
project_id bigint NOT NULL,
deployed boolean DEFAULT false NOT NULL,
artifacts_archive_id bigint
artifacts_archive_id bigint,
pages_deployment_id bigint
);
CREATE TABLE project_repositories (
......@@ -20819,6 +20820,8 @@ CREATE INDEX index_project_mirror_data_on_status ON project_mirror_data USING bt
CREATE INDEX index_project_pages_metadata_on_artifacts_archive_id ON project_pages_metadata USING btree (artifacts_archive_id);
CREATE INDEX index_project_pages_metadata_on_pages_deployment_id ON project_pages_metadata USING btree (pages_deployment_id);
CREATE UNIQUE INDEX index_project_pages_metadata_on_project_id ON project_pages_metadata USING btree (project_id);
CREATE INDEX index_project_pages_metadata_on_project_id_and_deployed_is_true ON project_pages_metadata USING btree (project_id) WHERE (deployed = true);
......@@ -21876,6 +21879,9 @@ ALTER TABLE ONLY notification_settings
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_0d3f677137 FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE;
ALTER TABLE ONLY project_pages_metadata
ADD CONSTRAINT fk_0fd5b22688 FOREIGN KEY (pages_deployment_id) REFERENCES pages_deployments(id) ON DELETE SET NULL;
ALTER TABLE ONLY group_deletion_schedules
ADD CONSTRAINT fk_11e3ebfcdd FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
......
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