Commit bd2d7e45 authored by Steve Abrams's avatar Steve Abrams

Merge branch 'issue_227753-remove_backup_labels_table' into 'master'

Remove backup_labels temporary table

See merge request gitlab-org/gitlab!54856
parents b7d6bb36 c845ccf9
---
title: Remove backup_labels table
merge_request: 54856
author:
type: other
# frozen_string_literal: true
class RemoveBackupLabelsForeignKeys < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
with_lock_retries do
remove_foreign_key_if_exists(:backup_labels, :projects)
remove_foreign_key_if_exists(:backup_labels, :namespaces)
end
end
def down
add_concurrent_foreign_key(:backup_labels, :projects, column: :project_id, on_delete: :cascade)
add_concurrent_foreign_key(:backup_labels, :namespaces, column: :group_id, on_delete: :cascade)
end
end
# frozen_string_literal: true
class RemoveBackupLabelsTable < ActiveRecord::Migration[6.0]
DOWNTIME = false
def up
drop_table :backup_labels
end
def down
create_table :backup_labels, id: false do |t|
t.integer :id, null: false
t.string :title
t.string :color
t.integer :project_id
t.timestamps null: true # rubocop:disable Migration/Timestamps
t.boolean :template, default: false
t.string :description
t.text :description_html
t.string :type
t.integer :group_id
t.integer :cached_markdown_version
t.integer :restore_action
t.string :new_title
end
execute 'ALTER TABLE backup_labels ADD PRIMARY KEY (id)'
add_index :backup_labels, [:group_id, :project_id, :title], name: 'backup_labels_group_id_project_id_title_idx', unique: true
add_index :backup_labels, [:group_id, :title], where: 'project_id = NULL::integer', name: 'backup_labels_group_id_title_idx'
add_index :backup_labels, :project_id, name: 'backup_labels_project_id_idx'
add_index :backup_labels, :template, name: 'backup_labels_template_idx', where: 'template'
add_index :backup_labels, :title, name: 'backup_labels_title_idx'
add_index :backup_labels, [:type, :project_id], name: 'backup_labels_type_project_id_idx'
end
end
0bccf1ff356a4b9c08d472e8b63070b497f331c2dfaded1bdb2cf01860df8903
\ No newline at end of file
b2508d46edbfbba24df65731f6e285886acbb6352a900dd1c6a985a686252ef0
\ No newline at end of file
...@@ -9747,23 +9747,6 @@ CREATE SEQUENCE background_migration_jobs_id_seq ...@@ -9747,23 +9747,6 @@ CREATE SEQUENCE background_migration_jobs_id_seq
ALTER SEQUENCE background_migration_jobs_id_seq OWNED BY background_migration_jobs.id; ALTER SEQUENCE background_migration_jobs_id_seq OWNED BY background_migration_jobs.id;
CREATE TABLE backup_labels (
id integer NOT NULL,
title character varying,
color character varying,
project_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone,
template boolean DEFAULT false,
description character varying,
description_html text,
type character varying,
group_id integer,
cached_markdown_version integer,
restore_action integer,
new_title character varying
);
CREATE TABLE badges ( CREATE TABLE badges (
id integer NOT NULL, id integer NOT NULL,
link_url character varying NOT NULL, link_url character varying NOT NULL,
...@@ -19824,9 +19807,6 @@ ALTER TABLE ONLY aws_roles ...@@ -19824,9 +19807,6 @@ ALTER TABLE ONLY aws_roles
ALTER TABLE ONLY background_migration_jobs ALTER TABLE ONLY background_migration_jobs
ADD CONSTRAINT background_migration_jobs_pkey PRIMARY KEY (id); ADD CONSTRAINT background_migration_jobs_pkey PRIMARY KEY (id);
ALTER TABLE ONLY backup_labels
ADD CONSTRAINT backup_labels_pkey PRIMARY KEY (id);
ALTER TABLE ONLY badges ALTER TABLE ONLY badges
ADD CONSTRAINT badges_pkey PRIMARY KEY (id); ADD CONSTRAINT badges_pkey PRIMARY KEY (id);
...@@ -21278,18 +21258,6 @@ CREATE UNIQUE INDEX any_approver_project_rule_type_unique_index ON approval_proj ...@@ -21278,18 +21258,6 @@ CREATE UNIQUE INDEX any_approver_project_rule_type_unique_index ON approval_proj
CREATE INDEX approval_mr_rule_index_merge_request_id ON approval_merge_request_rules USING btree (merge_request_id); CREATE INDEX approval_mr_rule_index_merge_request_id ON approval_merge_request_rules USING btree (merge_request_id);
CREATE UNIQUE INDEX backup_labels_group_id_project_id_title_idx ON backup_labels USING btree (group_id, project_id, title);
CREATE INDEX backup_labels_group_id_title_idx ON backup_labels USING btree (group_id, title) WHERE (project_id = NULL::integer);
CREATE INDEX backup_labels_project_id_idx ON backup_labels USING btree (project_id);
CREATE INDEX backup_labels_template_idx ON backup_labels USING btree (template) WHERE template;
CREATE INDEX backup_labels_title_idx ON backup_labels USING btree (title);
CREATE INDEX backup_labels_type_project_id_idx ON backup_labels USING btree (type, project_id);
CREATE UNIQUE INDEX bulk_import_trackers_uniq_relation_by_entity ON bulk_import_trackers USING btree (bulk_import_entity_id, relation); CREATE UNIQUE INDEX bulk_import_trackers_uniq_relation_by_entity ON bulk_import_trackers USING btree (bulk_import_entity_id, relation);
CREATE INDEX ci_builds_gitlab_monitor_metrics ON ci_builds USING btree (status, created_at, project_id) WHERE ((type)::text = 'Ci::Build'::text); CREATE INDEX ci_builds_gitlab_monitor_metrics ON ci_builds USING btree (status, created_at, project_id) WHERE ((type)::text = 'Ci::Build'::text);
...@@ -24470,9 +24438,6 @@ ALTER TABLE ONLY vulnerabilities ...@@ -24470,9 +24438,6 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY labels ALTER TABLE ONLY labels
ADD CONSTRAINT fk_7de4989a69 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_7de4989a69 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY backup_labels
ADD CONSTRAINT fk_7de4989a69 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY merge_requests ALTER TABLE ONLY merge_requests
ADD CONSTRAINT fk_7e85395a64 FOREIGN KEY (sprint_id) REFERENCES sprints(id) ON DELETE CASCADE; ADD CONSTRAINT fk_7e85395a64 FOREIGN KEY (sprint_id) REFERENCES sprints(id) ON DELETE CASCADE;
...@@ -25988,9 +25953,6 @@ ALTER TABLE ONLY serverless_domain_cluster ...@@ -25988,9 +25953,6 @@ ALTER TABLE ONLY serverless_domain_cluster
ALTER TABLE ONLY labels ALTER TABLE ONLY labels
ADD CONSTRAINT fk_rails_c1ac5161d8 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_c1ac5161d8 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY backup_labels
ADD CONSTRAINT fk_rails_c1ac5161d8 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY project_feature_usages ALTER TABLE ONLY project_feature_usages
ADD CONSTRAINT fk_rails_c22a50024b FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_c22a50024b FOREIGN KEY (project_id) REFERENCES projects(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