Commit 4b66d81b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Add iteration_id column to lists

Also adds a foreign key constraint and cascades deletes when the
iteration is deleted
parent 27da16c9
---
title: Add iteration_id column to lists
merge_request: 48103
author:
type: added
# frozen_string_literal: true
class AddIterationIdToLists < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :lists, :iteration_id, :bigint
end
end
# frozen_string_literal: true
class AddIterationListsForeignKey < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
INDEX_NAME = 'index_lists_on_iteration_id'
disable_ddl_transaction!
def up
add_concurrent_index :lists, :iteration_id, name: INDEX_NAME
add_concurrent_foreign_key :lists, :sprints, column: :iteration_id, on_delete: :cascade
end
def down
remove_foreign_key_if_exists :lists, :sprints, column: :iteration_id
remove_concurrent_index_by_name :lists, INDEX_NAME
end
end
6d2e6937c9e41975b1fd402bf2985796792a1e5f8e4f4f98bc76b65ff73c4e02
\ No newline at end of file
c7567489156bbc047cf9f7827f060ad507fd5d328179f2796566a7dc54806e3e
\ No newline at end of file
......@@ -13593,7 +13593,8 @@ CREATE TABLE lists (
milestone_id integer,
max_issue_count integer DEFAULT 0 NOT NULL,
max_issue_weight integer DEFAULT 0 NOT NULL,
limit_metric character varying(20)
limit_metric character varying(20),
iteration_id bigint
);
CREATE SEQUENCE lists_id_seq
......@@ -21522,6 +21523,8 @@ CREATE UNIQUE INDEX index_list_user_preferences_on_user_id_and_list_id ON list_u
CREATE UNIQUE INDEX index_lists_on_board_id_and_label_id ON lists USING btree (board_id, label_id);
CREATE INDEX index_lists_on_iteration_id ON lists USING btree (iteration_id);
CREATE INDEX index_lists_on_label_id ON lists USING btree (label_id);
CREATE INDEX index_lists_on_list_type ON lists USING btree (list_type);
......@@ -23174,6 +23177,9 @@ ALTER TABLE ONLY notes
ALTER TABLE ONLY members
ADD CONSTRAINT fk_2e88fb7ce9 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
ALTER TABLE ONLY lists
ADD CONSTRAINT fk_30f2a831f4 FOREIGN KEY (iteration_id) REFERENCES sprints(id) ON DELETE CASCADE;
ALTER TABLE ONLY approvals
ADD CONSTRAINT fk_310d714958 FOREIGN KEY (merge_request_id) REFERENCES merge_requests(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