Commit 7b2cd340 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '211660-jira-imports' into 'master'

Add jira_imports table to track Jira imports

See merge request gitlab-org/gitlab!28108
parents 93cdc193 5b737642
---
title: Add jira_imports table to track current jira import progress as well as historical imports data
merge_request: 28108
author:
type: added
# frozen_string_literal: true
class CreateJiraImportsTable < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def change
create_table :jira_imports do |t|
t.integer :project_id, null: false, limit: 8
t.integer :user_id, limit: 8
t.integer :label_id, limit: 8
t.timestamps_with_timezone
t.datetime_with_timezone :finished_at
t.integer :jira_project_xid, null: false, limit: 8
t.integer :total_issue_count, null: false, default: 0, limit: 4
t.integer :imported_issues_count, null: false, default: 0, limit: 4
t.integer :failed_to_import_count, null: false, default: 0, limit: 4
t.integer :status, limit: 2, null: false, default: 0
t.string :jid, limit: 255
t.string :jira_project_key, null: false, limit: 255
t.string :jira_project_name, null: false, limit: 255
end
add_index :jira_imports, [:project_id, :jira_project_key], name: 'index_jira_imports_on_project_id_and_jira_project_key'
end
end
# frozen_string_literal: true
class AddProjectsFkToJiraImportsTable < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_foreign_key :jira_imports, :projects, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey
end
end
def down
with_lock_retries do
remove_foreign_key :jira_imports, :projects
end
end
end
# frozen_string_literal: true
class AddUsersFkToJiraImportsTable < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_foreign_key :jira_imports, :users, on_delete: :nullify # rubocop:disable Migration/AddConcurrentForeignKey
end
end
def down
with_lock_retries do
remove_foreign_key :jira_imports, :users
end
end
end
# frozen_string_literal: true
class AddUsersFkIndexOnJiraImportsTable < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :jira_imports, :user_id
end
def down
remove_concurrent_index :jira_imports, :user_id
end
end
# frozen_string_literal: true
class AddLabelsFkToJiraImportsTable < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_foreign_key :jira_imports, :labels, on_delete: :nullify # rubocop:disable Migration/AddConcurrentForeignKey
end
end
def down
with_lock_retries do
remove_foreign_key :jira_imports, :labels
end
end
end
# frozen_string_literal: true
class AddLabelsFkIndexOnJiraImportsTable < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index :jira_imports, :label_id
end
def down
remove_concurrent_index :jira_imports, :label_id
end
end
...@@ -3304,6 +3304,33 @@ CREATE SEQUENCE public.jira_connect_subscriptions_id_seq ...@@ -3304,6 +3304,33 @@ CREATE SEQUENCE public.jira_connect_subscriptions_id_seq
ALTER SEQUENCE public.jira_connect_subscriptions_id_seq OWNED BY public.jira_connect_subscriptions.id; ALTER SEQUENCE public.jira_connect_subscriptions_id_seq OWNED BY public.jira_connect_subscriptions.id;
CREATE TABLE public.jira_imports (
id bigint NOT NULL,
project_id bigint NOT NULL,
user_id bigint,
label_id bigint,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
finished_at timestamp with time zone,
jira_project_xid bigint NOT NULL,
total_issue_count integer DEFAULT 0 NOT NULL,
imported_issues_count integer DEFAULT 0 NOT NULL,
failed_to_import_count integer DEFAULT 0 NOT NULL,
status smallint DEFAULT 0 NOT NULL,
jid character varying(255),
jira_project_key character varying(255) NOT NULL,
jira_project_name character varying(255) NOT NULL
);
CREATE SEQUENCE public.jira_imports_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.jira_imports_id_seq OWNED BY public.jira_imports.id;
CREATE TABLE public.jira_tracker_data ( CREATE TABLE public.jira_tracker_data (
id bigint NOT NULL, id bigint NOT NULL,
service_id integer NOT NULL, service_id integer NOT NULL,
...@@ -7119,6 +7146,8 @@ ALTER TABLE ONLY public.jira_connect_installations ALTER COLUMN id SET DEFAULT n ...@@ -7119,6 +7146,8 @@ ALTER TABLE ONLY public.jira_connect_installations ALTER COLUMN id SET DEFAULT n
ALTER TABLE ONLY public.jira_connect_subscriptions ALTER COLUMN id SET DEFAULT nextval('public.jira_connect_subscriptions_id_seq'::regclass); ALTER TABLE ONLY public.jira_connect_subscriptions ALTER COLUMN id SET DEFAULT nextval('public.jira_connect_subscriptions_id_seq'::regclass);
ALTER TABLE ONLY public.jira_imports ALTER COLUMN id SET DEFAULT nextval('public.jira_imports_id_seq'::regclass);
ALTER TABLE ONLY public.jira_tracker_data ALTER COLUMN id SET DEFAULT nextval('public.jira_tracker_data_id_seq'::regclass); ALTER TABLE ONLY public.jira_tracker_data ALTER COLUMN id SET DEFAULT nextval('public.jira_tracker_data_id_seq'::regclass);
ALTER TABLE ONLY public.keys ALTER COLUMN id SET DEFAULT nextval('public.keys_id_seq'::regclass); ALTER TABLE ONLY public.keys ALTER COLUMN id SET DEFAULT nextval('public.keys_id_seq'::regclass);
...@@ -7872,6 +7901,9 @@ ALTER TABLE ONLY public.jira_connect_installations ...@@ -7872,6 +7901,9 @@ ALTER TABLE ONLY public.jira_connect_installations
ALTER TABLE ONLY public.jira_connect_subscriptions ALTER TABLE ONLY public.jira_connect_subscriptions
ADD CONSTRAINT jira_connect_subscriptions_pkey PRIMARY KEY (id); ADD CONSTRAINT jira_connect_subscriptions_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.jira_imports
ADD CONSTRAINT jira_imports_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.jira_tracker_data ALTER TABLE ONLY public.jira_tracker_data
ADD CONSTRAINT jira_tracker_data_pkey PRIMARY KEY (id); ADD CONSTRAINT jira_tracker_data_pkey PRIMARY KEY (id);
...@@ -9243,6 +9275,12 @@ CREATE UNIQUE INDEX index_jira_connect_installations_on_client_key ON public.jir ...@@ -9243,6 +9275,12 @@ CREATE UNIQUE INDEX index_jira_connect_installations_on_client_key ON public.jir
CREATE INDEX index_jira_connect_subscriptions_on_namespace_id ON public.jira_connect_subscriptions USING btree (namespace_id); CREATE INDEX index_jira_connect_subscriptions_on_namespace_id ON public.jira_connect_subscriptions USING btree (namespace_id);
CREATE INDEX index_jira_imports_on_label_id ON public.jira_imports USING btree (label_id);
CREATE INDEX index_jira_imports_on_project_id_and_jira_project_key ON public.jira_imports USING btree (project_id, jira_project_key);
CREATE INDEX index_jira_imports_on_user_id ON public.jira_imports USING btree (user_id);
CREATE INDEX index_jira_tracker_data_on_service_id ON public.jira_tracker_data USING btree (service_id); CREATE INDEX index_jira_tracker_data_on_service_id ON public.jira_tracker_data USING btree (service_id);
CREATE UNIQUE INDEX index_keys_on_fingerprint ON public.keys USING btree (fingerprint); CREATE UNIQUE INDEX index_keys_on_fingerprint ON public.keys USING btree (fingerprint);
...@@ -11218,6 +11256,9 @@ ALTER TABLE ONLY public.deployment_clusters ...@@ -11218,6 +11256,9 @@ ALTER TABLE ONLY public.deployment_clusters
ALTER TABLE ONLY public.evidences ALTER TABLE ONLY public.evidences
ADD CONSTRAINT fk_rails_6388b435a6 FOREIGN KEY (release_id) REFERENCES public.releases(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_6388b435a6 FOREIGN KEY (release_id) REFERENCES public.releases(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.jira_imports
ADD CONSTRAINT fk_rails_63cbe52ada FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.vulnerability_occurrence_pipelines ALTER TABLE ONLY public.vulnerability_occurrence_pipelines
ADD CONSTRAINT fk_rails_6421e35d7d FOREIGN KEY (pipeline_id) REFERENCES public.ci_pipelines(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_6421e35d7d FOREIGN KEY (pipeline_id) REFERENCES public.ci_pipelines(id) ON DELETE CASCADE;
...@@ -11257,6 +11298,9 @@ ALTER TABLE ONLY public.operations_feature_flags_clients ...@@ -11257,6 +11298,9 @@ ALTER TABLE ONLY public.operations_feature_flags_clients
ALTER TABLE ONLY public.web_hook_logs ALTER TABLE ONLY public.web_hook_logs
ADD CONSTRAINT fk_rails_666826e111 FOREIGN KEY (web_hook_id) REFERENCES public.web_hooks(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_666826e111 FOREIGN KEY (web_hook_id) REFERENCES public.web_hooks(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.jira_imports
ADD CONSTRAINT fk_rails_675d38c03b FOREIGN KEY (label_id) REFERENCES public.labels(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.geo_hashed_storage_migrated_events ALTER TABLE ONLY public.geo_hashed_storage_migrated_events
ADD CONSTRAINT fk_rails_687ed7d7c5 FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_687ed7d7c5 FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
...@@ -11671,6 +11715,9 @@ ALTER TABLE ONLY public.vulnerability_issue_links ...@@ -11671,6 +11715,9 @@ ALTER TABLE ONLY public.vulnerability_issue_links
ALTER TABLE ONLY public.geo_hashed_storage_attachments_events ALTER TABLE ONLY public.geo_hashed_storage_attachments_events
ADD CONSTRAINT fk_rails_d496b088e9 FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_d496b088e9 FOREIGN KEY (project_id) REFERENCES public.projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY public.jira_imports
ADD CONSTRAINT fk_rails_da617096ce FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.dependency_proxy_blobs ALTER TABLE ONLY public.dependency_proxy_blobs
ADD CONSTRAINT fk_rails_db58bbc5d7 FOREIGN KEY (group_id) REFERENCES public.namespaces(id) ON DELETE CASCADE; ADD CONSTRAINT fk_rails_db58bbc5d7 FOREIGN KEY (group_id) REFERENCES public.namespaces(id) ON DELETE CASCADE;
...@@ -12854,5 +12901,11 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -12854,5 +12901,11 @@ COPY "schema_migrations" (version) FROM STDIN;
20200325152327 20200325152327
20200325160952 20200325160952
20200325183636 20200325183636
20200326114443
20200326124443
20200326134443
20200326135443
20200326144443
20200326145443
\. \.
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