From fcc36095de58fa6166c055c27a75bd7d061c77dc Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Mon, 15 Apr 2024 16:35:31 +0200 Subject: [PATCH 1/3] Add imported column to resources This adds several migrations that add an imported column to resources that will display an imported icon in the UI if they are imported. The column is a smallint type that will use an enum and default to 0. The default value 0 will indicate the resource was not imported. Any other value will indicate the importer used (e.g. github, bitbucket, etc.) Changelog: added --- .../20240415134942_add_imported_to_notes.rb | 31 +++++++++++++++++ ...15135009_add_imported_to_merge_requests.rb | 31 +++++++++++++++++ .../20240415135029_add_imported_to_issues.rb | 31 +++++++++++++++++ .../20240415135048_add_imported_to_epics.rb | 31 +++++++++++++++++ .../20240415135110_add_imported_to_events.rb | 31 +++++++++++++++++ ...20240415135132_add_imported_to_snippets.rb | 31 +++++++++++++++++ .../20240415135156_add_imported_to_designs.rb | 31 +++++++++++++++++ ...4_add_imported_to_resource_event_tables.rb | 33 +++++++++++++++++++ ...64720_add_imported_to_temp_notes_backup.rb | 31 +++++++++++++++++ db/schema_migrations/20240415134942 | 1 + db/schema_migrations/20240415135009 | 1 + db/schema_migrations/20240415135029 | 1 + db/schema_migrations/20240415135048 | 1 + db/schema_migrations/20240415135110 | 1 + db/schema_migrations/20240415135132 | 1 + db/schema_migrations/20240415135156 | 1 + db/schema_migrations/20240415135324 | 1 + db/schema_migrations/20240415164720 | 1 + db/structure.sql | 21 +++++++++--- 19 files changed, 306 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20240415134942_add_imported_to_notes.rb create mode 100644 db/migrate/20240415135009_add_imported_to_merge_requests.rb create mode 100644 db/migrate/20240415135029_add_imported_to_issues.rb create mode 100644 db/migrate/20240415135048_add_imported_to_epics.rb create mode 100644 db/migrate/20240415135110_add_imported_to_events.rb create mode 100644 db/migrate/20240415135132_add_imported_to_snippets.rb create mode 100644 db/migrate/20240415135156_add_imported_to_designs.rb create mode 100644 db/migrate/20240415135324_add_imported_to_resource_event_tables.rb create mode 100644 db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb create mode 100644 db/schema_migrations/20240415134942 create mode 100644 db/schema_migrations/20240415135009 create mode 100644 db/schema_migrations/20240415135029 create mode 100644 db/schema_migrations/20240415135048 create mode 100644 db/schema_migrations/20240415135110 create mode 100644 db/schema_migrations/20240415135132 create mode 100644 db/schema_migrations/20240415135156 create mode 100644 db/schema_migrations/20240415135324 create mode 100644 db/schema_migrations/20240415164720 diff --git a/db/migrate/20240415134942_add_imported_to_notes.rb b/db/migrate/20240415134942_add_imported_to_notes.rb new file mode 100644 index 00000000000000..09dc3f2c637a19 --- /dev/null +++ b/db/migrate/20240415134942_add_imported_to_notes.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToNotes < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :notes, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415135009_add_imported_to_merge_requests.rb b/db/migrate/20240415135009_add_imported_to_merge_requests.rb new file mode 100644 index 00000000000000..d96d6a7293494b --- /dev/null +++ b/db/migrate/20240415135009_add_imported_to_merge_requests.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToMergeRequests < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :merge_requests, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415135029_add_imported_to_issues.rb b/db/migrate/20240415135029_add_imported_to_issues.rb new file mode 100644 index 00000000000000..cb2fc51f1701f7 --- /dev/null +++ b/db/migrate/20240415135029_add_imported_to_issues.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToIssues < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :issues, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415135048_add_imported_to_epics.rb b/db/migrate/20240415135048_add_imported_to_epics.rb new file mode 100644 index 00000000000000..643a6c0384d32d --- /dev/null +++ b/db/migrate/20240415135048_add_imported_to_epics.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToEpics < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :epics, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415135110_add_imported_to_events.rb b/db/migrate/20240415135110_add_imported_to_events.rb new file mode 100644 index 00000000000000..b256b6ffa93e45 --- /dev/null +++ b/db/migrate/20240415135110_add_imported_to_events.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToEvents < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :events, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415135132_add_imported_to_snippets.rb b/db/migrate/20240415135132_add_imported_to_snippets.rb new file mode 100644 index 00000000000000..decbae6c508714 --- /dev/null +++ b/db/migrate/20240415135132_add_imported_to_snippets.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToSnippets < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :snippets, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415135156_add_imported_to_designs.rb b/db/migrate/20240415135156_add_imported_to_designs.rb new file mode 100644 index 00000000000000..cb26d8ac21bb39 --- /dev/null +++ b/db/migrate/20240415135156_add_imported_to_designs.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToDesigns < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :design_management_designs, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415135324_add_imported_to_resource_event_tables.rb b/db/migrate/20240415135324_add_imported_to_resource_event_tables.rb new file mode 100644 index 00000000000000..ed116442b3ebfc --- /dev/null +++ b/db/migrate/20240415135324_add_imported_to_resource_event_tables.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToResourceEventTables < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :resource_state_events, :imported, :integer, default: 0, null: false, limit: 2 + add_column :resource_label_events, :imported, :integer, default: 0, null: false, limit: 2 + add_column :resource_milestone_events, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb b/db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb new file mode 100644 index 00000000000000..88d8ed5633f94c --- /dev/null +++ b/db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +# See https://docs.gitlab.com/ee/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImportedToTempNotesBackup < Gitlab::Database::Migration[2.2] + # When using the methods "add_concurrent_index" or "remove_concurrent_index" + # you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + # + # Configure the `gitlab_schema` to perform data manipulation (DML). + # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html + # restrict_gitlab_migration gitlab_schema: :gitlab_main + + # Add dependent 'batched_background_migrations.queued_migration_version' values. + # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] + milestone '16.11' + + def change + add_column :temp_notes_backup, :imported, :integer, default: 0, null: false, limit: 2 + end +end diff --git a/db/schema_migrations/20240415134942 b/db/schema_migrations/20240415134942 new file mode 100644 index 00000000000000..e7b543b74997b3 --- /dev/null +++ b/db/schema_migrations/20240415134942 @@ -0,0 +1 @@ +d5e6e6528c8f58d82c666d81e18da6247886a23aa5722fb371cea23b0a614d48 \ No newline at end of file diff --git a/db/schema_migrations/20240415135009 b/db/schema_migrations/20240415135009 new file mode 100644 index 00000000000000..4f98135f7d138e --- /dev/null +++ b/db/schema_migrations/20240415135009 @@ -0,0 +1 @@ +d210368410e6d03c57199d1b4fe75652d49da8260a91a238a684e39349546a87 \ No newline at end of file diff --git a/db/schema_migrations/20240415135029 b/db/schema_migrations/20240415135029 new file mode 100644 index 00000000000000..3647314d83a690 --- /dev/null +++ b/db/schema_migrations/20240415135029 @@ -0,0 +1 @@ +83b01048cf6d8dd770de7d085333516e84625535ebd238a91a8fd3919461717b \ No newline at end of file diff --git a/db/schema_migrations/20240415135048 b/db/schema_migrations/20240415135048 new file mode 100644 index 00000000000000..c807412fd6ba5b --- /dev/null +++ b/db/schema_migrations/20240415135048 @@ -0,0 +1 @@ +da4fac700bb88854534542a03dc73ed495d39c7ee4cfecdb4721227e652a9dd6 \ No newline at end of file diff --git a/db/schema_migrations/20240415135110 b/db/schema_migrations/20240415135110 new file mode 100644 index 00000000000000..546546f26c166e --- /dev/null +++ b/db/schema_migrations/20240415135110 @@ -0,0 +1 @@ +7af637894b463cce350af704f2bb7ad76160f2aaa56ce94177f75367a70eeee0 \ No newline at end of file diff --git a/db/schema_migrations/20240415135132 b/db/schema_migrations/20240415135132 new file mode 100644 index 00000000000000..c0b9a8a69fde69 --- /dev/null +++ b/db/schema_migrations/20240415135132 @@ -0,0 +1 @@ +fd67478569eaea20f5e139f936cc6543027a3db5f4c15ae9aba927fd01d931e1 \ No newline at end of file diff --git a/db/schema_migrations/20240415135156 b/db/schema_migrations/20240415135156 new file mode 100644 index 00000000000000..a92443e4e2fa5e --- /dev/null +++ b/db/schema_migrations/20240415135156 @@ -0,0 +1 @@ +290a65b2b0cf3f82c94d29cd76e1f298b82766a0c7f0f25eaab517e028b7a023 \ No newline at end of file diff --git a/db/schema_migrations/20240415135324 b/db/schema_migrations/20240415135324 new file mode 100644 index 00000000000000..1f7c8b5f6748df --- /dev/null +++ b/db/schema_migrations/20240415135324 @@ -0,0 +1 @@ +95f6ecf12fee7db963b8e3e580b3cfc5ccf104fd0481af32604a9011ce33ad57 \ No newline at end of file diff --git a/db/schema_migrations/20240415164720 b/db/schema_migrations/20240415164720 new file mode 100644 index 00000000000000..6e79d26f682887 --- /dev/null +++ b/db/schema_migrations/20240415164720 @@ -0,0 +1 @@ +40d7a47f5eed49385ef83629c63b3103c450e382b3697510e39883056ec67712 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 0269e419e31c2a..2ec2a1443ffecf 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -8249,6 +8249,7 @@ CREATE TABLE design_management_designs ( cached_markdown_version integer, description text, description_html text, + imported 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)) @@ -8739,6 +8740,7 @@ CREATE TABLE epics ( total_opened_issue_count integer DEFAULT 0 NOT NULL, total_closed_issue_count integer DEFAULT 0 NOT NULL, issue_id integer, + imported smallint DEFAULT 0 NOT NULL, CONSTRAINT check_ca608c40b3 CHECK ((char_length(color) <= 7)), CONSTRAINT check_fcfb4a93ff CHECK ((lock_version IS NOT NULL)) ); @@ -8834,6 +8836,7 @@ CREATE TABLE events ( fingerprint bytea, id bigint NOT NULL, target_id bigint, + imported smallint DEFAULT 0 NOT NULL, CONSTRAINT check_97e06e05ad CHECK ((octet_length(fingerprint) <= 128)) ); @@ -10429,6 +10432,7 @@ CREATE TABLE issues ( namespace_id bigint, start_date date, tmp_epic_id bigint, + imported 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)) @@ -11331,6 +11335,7 @@ CREATE TABLE merge_requests ( merged_commit_sha bytea, override_requested_changes boolean DEFAULT false NOT NULL, head_pipeline_id_convert_to_bigint bigint, + imported smallint DEFAULT 0 NOT NULL, CONSTRAINT check_970d272570 CHECK ((lock_version IS NOT NULL)) ); @@ -12018,7 +12023,8 @@ CREATE TABLE notes ( last_edited_at timestamp with time zone, internal boolean DEFAULT false NOT NULL, id bigint NOT NULL, - namespace_id bigint + namespace_id bigint, + imported smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE notes_id_seq @@ -15243,7 +15249,8 @@ CREATE TABLE resource_label_events ( created_at timestamp with time zone NOT NULL, cached_markdown_version integer, reference text, - reference_html text + reference_html text, + imported smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE resource_label_events_id_seq @@ -15282,7 +15289,8 @@ CREATE TABLE resource_milestone_events ( milestone_id bigint, action smallint NOT NULL, state smallint NOT NULL, - created_at timestamp with time zone NOT NULL + created_at timestamp with time zone NOT NULL, + imported smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE resource_milestone_events_id_seq @@ -15306,6 +15314,7 @@ CREATE TABLE resource_state_events ( close_after_error_tracking_resolve boolean DEFAULT false NOT NULL, close_auto_resolve_prometheus_alert boolean DEFAULT false NOT NULL, source_merge_request_id bigint, + imported 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)))) ); @@ -16128,7 +16137,8 @@ CREATE TABLE snippets ( encrypted_secret_token character varying(255), encrypted_secret_token_iv character varying(255), secret boolean DEFAULT false NOT NULL, - repository_read_only boolean DEFAULT false NOT NULL + repository_read_only boolean DEFAULT false NOT NULL, + imported smallint DEFAULT 0 NOT NULL ); CREATE SEQUENCE snippets_id_seq @@ -16554,7 +16564,8 @@ CREATE TABLE temp_notes_backup ( last_edited_at timestamp with time zone, internal boolean NOT NULL, id bigint NOT NULL, - namespace_id bigint + namespace_id bigint, + imported smallint DEFAULT 0 NOT NULL ); CREATE TABLE term_agreements ( -- GitLab From 188ce3e54ae66dbced350d6dc38591c74846c571 Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Tue, 16 Apr 2024 08:13:00 +0200 Subject: [PATCH 2/3] Fix specs remove boilerplate --- .../20240415134942_add_imported_to_notes.rb | 24 +------------------ ...15135009_add_imported_to_merge_requests.rb | 24 +------------------ .../20240415135029_add_imported_to_issues.rb | 24 +------------------ .../20240415135048_add_imported_to_epics.rb | 24 +------------------ .../20240415135110_add_imported_to_events.rb | 24 +------------------ ...20240415135132_add_imported_to_snippets.rb | 24 +------------------ .../20240415135156_add_imported_to_designs.rb | 24 +------------------ ...4_add_imported_to_resource_event_tables.rb | 24 +------------------ ...64720_add_imported_to_temp_notes_backup.rb | 24 +------------------ ...opy_design_collection_model_attributes.yml | 1 + .../import_export/safe_model_attributes.yml | 6 +++++ spec/models/snippet_spec.rb | 3 ++- 12 files changed, 18 insertions(+), 208 deletions(-) diff --git a/db/migrate/20240415134942_add_imported_to_notes.rb b/db/migrate/20240415134942_add_imported_to_notes.rb index 09dc3f2c637a19..14cfad1f5cddb3 100644 --- a/db/migrate/20240415134942_add_imported_to_notes.rb +++ b/db/migrate/20240415134942_add_imported_to_notes.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToNotes < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :notes, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415135009_add_imported_to_merge_requests.rb b/db/migrate/20240415135009_add_imported_to_merge_requests.rb index d96d6a7293494b..4101eccb43d848 100644 --- a/db/migrate/20240415135009_add_imported_to_merge_requests.rb +++ b/db/migrate/20240415135009_add_imported_to_merge_requests.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToMergeRequests < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :merge_requests, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415135029_add_imported_to_issues.rb b/db/migrate/20240415135029_add_imported_to_issues.rb index cb2fc51f1701f7..28785862d7a2a8 100644 --- a/db/migrate/20240415135029_add_imported_to_issues.rb +++ b/db/migrate/20240415135029_add_imported_to_issues.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToIssues < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :issues, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415135048_add_imported_to_epics.rb b/db/migrate/20240415135048_add_imported_to_epics.rb index 643a6c0384d32d..f9f0bce6bab4df 100644 --- a/db/migrate/20240415135048_add_imported_to_epics.rb +++ b/db/migrate/20240415135048_add_imported_to_epics.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToEpics < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :epics, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415135110_add_imported_to_events.rb b/db/migrate/20240415135110_add_imported_to_events.rb index b256b6ffa93e45..49bc5e912541d9 100644 --- a/db/migrate/20240415135110_add_imported_to_events.rb +++ b/db/migrate/20240415135110_add_imported_to_events.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToEvents < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :events, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415135132_add_imported_to_snippets.rb b/db/migrate/20240415135132_add_imported_to_snippets.rb index decbae6c508714..2d1fdc71add3fa 100644 --- a/db/migrate/20240415135132_add_imported_to_snippets.rb +++ b/db/migrate/20240415135132_add_imported_to_snippets.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToSnippets < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :snippets, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415135156_add_imported_to_designs.rb b/db/migrate/20240415135156_add_imported_to_designs.rb index cb26d8ac21bb39..df5f2a11935403 100644 --- a/db/migrate/20240415135156_add_imported_to_designs.rb +++ b/db/migrate/20240415135156_add_imported_to_designs.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToDesigns < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :design_management_designs, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415135324_add_imported_to_resource_event_tables.rb b/db/migrate/20240415135324_add_imported_to_resource_event_tables.rb index ed116442b3ebfc..6eee5d0fbd235a 100644 --- a/db/migrate/20240415135324_add_imported_to_resource_event_tables.rb +++ b/db/migrate/20240415135324_add_imported_to_resource_event_tables.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToResourceEventTables < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :resource_state_events, :imported, :integer, default: 0, null: false, limit: 2 diff --git a/db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb b/db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb index 88d8ed5633f94c..73da8febbd7890 100644 --- a/db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb +++ b/db/migrate/20240415164720_add_imported_to_temp_notes_backup.rb @@ -1,29 +1,7 @@ # frozen_string_literal: true -# See https://docs.gitlab.com/ee/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddImportedToTempNotesBackup < Gitlab::Database::Migration[2.2] - # When using the methods "add_concurrent_index" or "remove_concurrent_index" - # you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - # - # Configure the `gitlab_schema` to perform data manipulation (DML). - # Visit: https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html - # restrict_gitlab_migration gitlab_schema: :gitlab_main - - # Add dependent 'batched_background_migrations.queued_migration_version' values. - # DEPENDENT_BATCHED_BACKGROUND_MIGRATIONS = [] - milestone '16.11' + milestone '17.0' def change add_column :temp_notes_backup, :imported, :integer, default: 0, null: false, limit: 2 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 fe1baeb7b67d2f..bf2626c06a380b 100644 --- a/lib/gitlab/design_management/copy_design_collection_model_attributes.yml +++ b/lib/gitlab/design_management/copy_design_collection_model_attributes.yml @@ -17,6 +17,7 @@ design_attributes: - filename - relative_position - description + - imported 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 2547f4abda054d..608f18305477c2 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -34,6 +34,7 @@ Issue: - external_key - issue_type - email_message_id +- imported Event: - id - target_type @@ -44,6 +45,7 @@ Event: - action - author_id - fingerprint +- imported WikiPage::Meta: - id - title @@ -87,6 +89,7 @@ Note: - confidential - last_edited_at - internal +- imported Notes::NoteMetadata: - note_id - email_participant @@ -133,6 +136,7 @@ ProjectSnippet: - file_name - type - visibility_level +- imported Release: - id - name @@ -217,6 +221,7 @@ MergeRequest: - allow_maintainer_to_push - merge_ref_sha - draft +- imported MergeRequestDiff: - id - state @@ -996,6 +1001,7 @@ Epic: - total_closed_issue_weight - total_opened_issue_count - total_closed_issue_count + - imported EpicIssue: - id - relative_position diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index ff1c5959cb0d35..a226a877f55ee9 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -856,7 +856,8 @@ def to_json(params = {}) 'url' => Gitlab::UrlBuilder.build(snippet), 'type' => 'PersonalSnippet', 'created_at' => be_like_time(snippet.created_at), - 'updated_at' => be_like_time(snippet.updated_at) + 'updated_at' => be_like_time(snippet.updated_at), + 'imported' => 0 ) end end -- GitLab From fb42f06aa9c50d5d6a5f142473e60ece84abd7f8 Mon Sep 17 00:00:00 2001 From: carlad-gl Date: Wed, 17 Apr 2024 12:03:32 +0200 Subject: [PATCH 3/3] Empty commit to trigger new pipeline -- GitLab