diff --git a/db/migrate/20240502084801_add_imported_from_columns.rb b/db/migrate/20240502084801_add_imported_from_columns.rb new file mode 100644 index 0000000000000000000000000000000000000000..c2be7e2af94b93addfec37f8347c793f86ed7a66 --- /dev/null +++ b/db/migrate/20240502084801_add_imported_from_columns.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +class AddImportedFromColumns < Gitlab::Database::Migration[2.2] + milestone '17.0' + + disable_ddl_transaction! + + def up + with_lock_retries do + add_column :design_management_designs, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :epics, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :events, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :issues, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :merge_requests, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :notes, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :resource_label_events, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :resource_milestone_events, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :resource_state_events, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :snippets, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + + with_lock_retries do + add_column :temp_notes_backup, + :imported_from, :integer, default: 0, null: false, limit: 2, if_not_exists: true + end + end + + def down + with_lock_retries do + remove_column :design_management_designs, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :epics, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :events, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :issues, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :merge_requests, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :notes, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :resource_label_events, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :resource_milestone_events, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :resource_state_events, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :snippets, :imported_from, :integer, if_exists: true + end + + with_lock_retries do + remove_column :temp_notes_backup, :imported_from, :integer, if_exists: true + end + end +end diff --git a/db/schema_migrations/20240502084801 b/db/schema_migrations/20240502084801 new file mode 100644 index 0000000000000000000000000000000000000000..2cb1e2926c8731c36685551f072e7c9fcdb63b6c --- /dev/null +++ b/db/schema_migrations/20240502084801 @@ -0,0 +1 @@ +ae4ebf4e33ff1b74bc4cb1101579e123a48fd373cde6b35e0dbee10bc516c728 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index a17da951ced64b44a86b3e52af1f9ca1d9774497..277c2d694629e8262029d7dfcf917915c7ed5a09 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -8412,6 +8412,7 @@ CREATE TABLE design_management_designs ( description text, description_html text, imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL, CONSTRAINT check_07155e2715 CHECK ((char_length((filename)::text) <= 255)), CONSTRAINT check_aaf9fa6ae5 CHECK ((char_length(description) <= 1000000)), CONSTRAINT check_cfb92df01a CHECK ((iid IS NOT NULL)) @@ -8925,6 +8926,7 @@ CREATE TABLE epics ( total_closed_issue_count integer DEFAULT 0 NOT NULL, issue_id integer, imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL, CONSTRAINT check_ca608c40b3 CHECK ((char_length(color) <= 7)), CONSTRAINT check_fcfb4a93ff CHECK ((lock_version IS NOT NULL)) ); @@ -9021,6 +9023,7 @@ CREATE TABLE events ( id bigint NOT NULL, target_id bigint, imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL, CONSTRAINT check_97e06e05ad CHECK ((octet_length(fingerprint) <= 128)) ); @@ -10632,6 +10635,7 @@ CREATE TABLE issues ( start_date date, tmp_epic_id bigint, imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL, CONSTRAINT check_2addf801cd CHECK ((work_item_type_id IS NOT NULL)), CONSTRAINT check_c33362cd43 CHECK ((namespace_id IS NOT NULL)), CONSTRAINT check_fba63f706d CHECK ((lock_version IS NOT NULL)) @@ -11533,6 +11537,7 @@ CREATE TABLE merge_requests ( override_requested_changes boolean DEFAULT false NOT NULL, head_pipeline_id_convert_to_bigint bigint, imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL, CONSTRAINT check_970d272570 CHECK ((lock_version IS NOT NULL)) ); @@ -12222,7 +12227,8 @@ CREATE TABLE notes ( internal boolean DEFAULT false NOT NULL, id bigint NOT NULL, namespace_id bigint, - imported smallint DEFAULT 0 NOT NULL + imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE notes_id_seq @@ -15449,7 +15455,8 @@ CREATE TABLE resource_label_events ( cached_markdown_version integer, reference text, reference_html text, - imported smallint DEFAULT 0 NOT NULL + imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE resource_label_events_id_seq @@ -15489,7 +15496,8 @@ CREATE TABLE resource_milestone_events ( action smallint NOT NULL, state smallint NOT NULL, created_at timestamp with time zone NOT NULL, - imported smallint DEFAULT 0 NOT NULL + imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE resource_milestone_events_id_seq @@ -15514,6 +15522,7 @@ CREATE TABLE resource_state_events ( close_auto_resolve_prometheus_alert boolean DEFAULT false NOT NULL, source_merge_request_id bigint, imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL, CONSTRAINT check_f0bcfaa3a2 CHECK ((char_length(source_commit) <= 40)), CONSTRAINT state_events_must_belong_to_issue_or_merge_request_or_epic CHECK ((((issue_id <> NULL::bigint) AND (merge_request_id IS NULL) AND (epic_id IS NULL)) OR ((issue_id IS NULL) AND (merge_request_id <> NULL::bigint) AND (epic_id IS NULL)) OR ((issue_id IS NULL) AND (merge_request_id IS NULL) AND (epic_id <> NULL::integer)))) ); @@ -16340,7 +16349,8 @@ CREATE TABLE snippets ( encrypted_secret_token_iv character varying(255), secret boolean DEFAULT false NOT NULL, repository_read_only boolean DEFAULT false NOT NULL, - imported smallint DEFAULT 0 NOT NULL + imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE snippets_id_seq @@ -16767,7 +16777,8 @@ CREATE TABLE temp_notes_backup ( internal boolean NOT NULL, id bigint NOT NULL, namespace_id bigint, - imported smallint DEFAULT 0 NOT NULL + imported smallint DEFAULT 0 NOT NULL, + imported_from smallint DEFAULT 0 NOT NULL ); CREATE TABLE term_agreements ( diff --git a/lib/gitlab/design_management/copy_design_collection_model_attributes.yml b/lib/gitlab/design_management/copy_design_collection_model_attributes.yml index bf2626c06a380b1a691584a0b61a74489c045da3..eb0847313322e3f04ad76db57a23001074393b28 100644 --- a/lib/gitlab/design_management/copy_design_collection_model_attributes.yml +++ b/lib/gitlab/design_management/copy_design_collection_model_attributes.yml @@ -18,6 +18,7 @@ design_attributes: - relative_position - description - imported + - imported_from version_attributes: - author_id diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 8c6990e3a34cf31fb8dc28ae14518bb9b8672c52..fa42b4f3a828f083adb1b2250e2730d5b005e565 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -35,6 +35,7 @@ Issue: - issue_type - email_message_id - imported +- imported_from Event: - id - target_type @@ -46,6 +47,7 @@ Event: - author_id - fingerprint - imported +- imported_from WikiPage::Meta: - id - title @@ -90,6 +92,7 @@ Note: - last_edited_at - internal - imported +- imported_from Notes::NoteMetadata: - note_id - email_participant @@ -137,6 +140,7 @@ ProjectSnippet: - type - visibility_level - imported +- imported_from Release: - id - name @@ -222,6 +226,7 @@ MergeRequest: - merge_ref_sha - draft - imported +- imported_from MergeRequestDiff: - id - state @@ -1002,6 +1007,7 @@ Epic: - total_opened_issue_count - total_closed_issue_count - imported + - imported_from EpicIssue: - id - relative_position