Commit c845ccf9 authored by Felipe Artur's avatar Felipe Artur

Remove backup_labels temporary table

Removes backup_labels table used
previously used by background migrations.
parent 63399d52
---
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
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 (
id integer NOT NULL,
link_url character varying NOT NULL,
......@@ -19818,9 +19801,6 @@ ALTER TABLE ONLY aws_roles
ALTER TABLE ONLY background_migration_jobs
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
ADD CONSTRAINT badges_pkey PRIMARY KEY (id);
......@@ -21266,18 +21246,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 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 INDEX ci_builds_gitlab_monitor_metrics ON ci_builds USING btree (status, created_at, project_id) WHERE ((type)::text = 'Ci::Build'::text);
......@@ -24456,9 +24424,6 @@ ALTER TABLE ONLY vulnerabilities
ALTER TABLE ONLY labels
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
ADD CONSTRAINT fk_7e85395a64 FOREIGN KEY (sprint_id) REFERENCES sprints(id) ON DELETE CASCADE;
......@@ -25974,9 +25939,6 @@ ALTER TABLE ONLY serverless_domain_cluster
ALTER TABLE ONLY labels
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
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