Commit 21ca8494 authored by Tiger Watson's avatar Tiger Watson

Merge branch 'create-ops-ff-issues-table' into 'master'

Create operations_feature_flags_issues Table

See merge request gitlab-org/gitlab!32876
parents 3ff24e33 41192423
---
title: Create operations_feature_flags_issues table
merge_request: 32876
author:
type: added
# frozen_string_literal: true
class CreateOperationsFeatureFlagsIssues < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
create_table :operations_feature_flags_issues do |t|
t.references :feature_flag, index: false, foreign_key: { on_delete: :cascade, to_table: :operations_feature_flags }, null: false
t.bigint :issue_id, null: false
t.index [:feature_flag_id, :issue_id], unique: true, name: :index_ops_feature_flags_issues_on_feature_flag_id_and_issue_id
t.index :issue_id
end
end
end
# frozen_string_literal: true
class AddForeignKeyToOpsFeatureFlagsIssues < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_foreign_key :operations_feature_flags_issues, :issues, column: :issue_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey
end
end
def down
with_lock_retries do
remove_foreign_key :operations_feature_flags_issues, column: :issue_id
end
end
end
......@@ -4487,6 +4487,21 @@ CREATE SEQUENCE public.operations_feature_flags_id_seq
ALTER SEQUENCE public.operations_feature_flags_id_seq OWNED BY public.operations_feature_flags.id;
CREATE TABLE public.operations_feature_flags_issues (
id bigint NOT NULL,
feature_flag_id bigint NOT NULL,
issue_id bigint NOT NULL
);
CREATE SEQUENCE public.operations_feature_flags_issues_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.operations_feature_flags_issues_id_seq OWNED BY public.operations_feature_flags_issues.id;
CREATE TABLE public.operations_scopes (
id bigint NOT NULL,
strategy_id bigint NOT NULL,
......@@ -7685,6 +7700,8 @@ ALTER TABLE ONLY public.operations_feature_flags ALTER COLUMN id SET DEFAULT nex
ALTER TABLE ONLY public.operations_feature_flags_clients ALTER COLUMN id SET DEFAULT nextval('public.operations_feature_flags_clients_id_seq'::regclass);
ALTER TABLE ONLY public.operations_feature_flags_issues ALTER COLUMN id SET DEFAULT nextval('public.operations_feature_flags_issues_id_seq'::regclass);
ALTER TABLE ONLY public.operations_scopes ALTER COLUMN id SET DEFAULT nextval('public.operations_scopes_id_seq'::regclass);
ALTER TABLE ONLY public.operations_strategies ALTER COLUMN id SET DEFAULT nextval('public.operations_strategies_id_seq'::regclass);
......@@ -8543,6 +8560,9 @@ ALTER TABLE ONLY public.operations_feature_flag_scopes
ALTER TABLE ONLY public.operations_feature_flags_clients
ADD CONSTRAINT operations_feature_flags_clients_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.operations_feature_flags_issues
ADD CONSTRAINT operations_feature_flags_issues_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.operations_feature_flags
ADD CONSTRAINT operations_feature_flags_pkey PRIMARY KEY (id);
......@@ -10193,6 +10213,8 @@ CREATE INDEX index_on_users_name_lower ON public.users USING btree (lower((name)
CREATE INDEX index_open_project_tracker_data_on_service_id ON public.open_project_tracker_data USING btree (service_id);
CREATE INDEX index_operations_feature_flags_issues_on_issue_id ON public.operations_feature_flags_issues USING btree (issue_id);
CREATE UNIQUE INDEX index_operations_feature_flags_on_project_id_and_iid ON public.operations_feature_flags USING btree (project_id, iid);
CREATE UNIQUE INDEX index_operations_feature_flags_on_project_id_and_name ON public.operations_feature_flags USING btree (project_id, name);
......@@ -10207,6 +10229,8 @@ CREATE UNIQUE INDEX index_operations_user_lists_on_project_id_and_iid ON public.
CREATE UNIQUE INDEX index_operations_user_lists_on_project_id_and_name ON public.operations_user_lists USING btree (project_id, name);
CREATE UNIQUE INDEX index_ops_feature_flags_issues_on_feature_flag_id_and_issue_id ON public.operations_feature_flags_issues USING btree (feature_flag_id, issue_id);
CREATE UNIQUE INDEX index_ops_strategies_user_lists_on_strategy_id_and_user_list_id ON public.operations_strategies_user_lists USING btree (strategy_id, user_list_id);
CREATE UNIQUE INDEX index_packages_build_infos_on_package_id ON public.packages_build_infos USING btree (package_id);
......@@ -12111,6 +12135,9 @@ ALTER TABLE ONLY public.geo_hashed_storage_migrated_events
ALTER TABLE ONLY public.plan_limits
ADD CONSTRAINT fk_rails_69f8b6184f FOREIGN KEY (plan_id) REFERENCES public.plans(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.operations_feature_flags_issues
ADD CONSTRAINT fk_rails_6a8856ca4f FOREIGN KEY (feature_flag_id) REFERENCES public.operations_feature_flags(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.prometheus_alerts
ADD CONSTRAINT fk_rails_6d9b283465 FOREIGN KEY (environment_id) REFERENCES public.environments(id) ON DELETE CASCADE;
......@@ -12666,6 +12693,9 @@ ALTER TABLE ONLY public.ci_runner_namespaces
ALTER TABLE ONLY public.requirements_management_test_reports
ADD CONSTRAINT fk_rails_fb3308ad55 FOREIGN KEY (requirement_id) REFERENCES public.requirements(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.operations_feature_flags_issues
ADD CONSTRAINT fk_rails_fb4d2a7cb1 FOREIGN KEY (issue_id) REFERENCES public.issues(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.board_project_recent_visits
ADD CONSTRAINT fk_rails_fb6fc419cb FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
......@@ -13936,5 +13966,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200525114553
20200525121014
20200526120714
20200526164946
20200526164947
\.
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