diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-15 21:07:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-15 21:07:42 +0000 |
commit | 2b5079efdb7c4e7d5a607d95747ddeb0b8af9678 (patch) | |
tree | 6d226593a137e111c7d4075ec22d6c4d328c3b57 /db | |
parent | 5ff1f808adf841bca979cb2fac6bdfa9c449d028 (diff) | |
download | gitlab-ce-2b5079efdb7c4e7d5a607d95747ddeb0b8af9678.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/docs/design_management_repository_states.yml | 10 | ||||
-rw-r--r-- | db/migrate/20230322164031_create_design_management_repository_states.rb | 41 | ||||
-rw-r--r-- | db/migrate/20230509085428_change_organizations_sequence.rb | 12 | ||||
-rw-r--r-- | db/migrate/20230509115525_add_name_to_organization.rb | 20 | ||||
-rw-r--r-- | db/migrate/20230509131736_add_default_organization.rb | 16 | ||||
-rw-r--r-- | db/migrate/20230515111314_add_text_limit_on_organization_name.rb | 13 | ||||
-rw-r--r-- | db/schema_migrations/20230322164031 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20230509085428 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20230509115525 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20230509131736 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20230515111314 | 1 | ||||
-rw-r--r-- | db/structure.sql | 36 |
12 files changed, 150 insertions, 3 deletions
diff --git a/db/docs/design_management_repository_states.yml b/db/docs/design_management_repository_states.yml new file mode 100644 index 00000000000..3a8fa59fb42 --- /dev/null +++ b/db/docs/design_management_repository_states.yml @@ -0,0 +1,10 @@ +--- +table_name: design_management_repository_states +classes: +classes: [] +feature_categories: +- geo_replication +description: Separate table for Design Repository verification states +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/113958 +milestone: '16.0' +gitlab_schema: gitlab_main diff --git a/db/migrate/20230322164031_create_design_management_repository_states.rb b/db/migrate/20230322164031_create_design_management_repository_states.rb new file mode 100644 index 00000000000..0c906a45ae8 --- /dev/null +++ b/db/migrate/20230322164031_create_design_management_repository_states.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +class CreateDesignManagementRepositoryStates < Gitlab::Database::Migration[2.1] + VERIFICATION_STATE_INDEX_NAME = "index_design_management_repository_states_on_verification_state" + PENDING_VERIFICATION_INDEX_NAME = "index_design_management_repository_states_pending_verification" + FAILED_VERIFICATION_INDEX_NAME = "index_design_management_repository_states_failed_verification" + NEEDS_VERIFICATION_INDEX_NAME = "index_design_management_repository_states_needs_verification" + + enable_lock_retries! + + def up + create_table :design_management_repository_states, id: false do |t| + t.datetime_with_timezone :verification_started_at + t.datetime_with_timezone :verification_retry_at + t.datetime_with_timezone :verified_at + t.references :design_management_repository, primary_key: true, default: nil, index: false, + foreign_key: { on_delete: :cascade } + t.integer :verification_state, default: 0, limit: 2, null: false + t.integer :verification_retry_count, default: 0, limit: 2, null: false + t.binary :verification_checksum, using: 'verification_checksum::bytea' + t.text :verification_failure, limit: 255 + + t.index :verification_state, name: VERIFICATION_STATE_INDEX_NAME + t.index :verified_at, + where: "(verification_state = 0)", + order: { verified_at: 'ASC NULLS FIRST' }, + name: PENDING_VERIFICATION_INDEX_NAME + t.index :verification_retry_at, + where: "(verification_state = 3)", + order: { verification_retry_at: 'ASC NULLS FIRST' }, + name: FAILED_VERIFICATION_INDEX_NAME + t.index :verification_state, + where: "(verification_state = 0 OR verification_state = 3)", + name: NEEDS_VERIFICATION_INDEX_NAME + end + end + + def down + drop_table :design_management_repository_states + end +end diff --git a/db/migrate/20230509085428_change_organizations_sequence.rb b/db/migrate/20230509085428_change_organizations_sequence.rb new file mode 100644 index 00000000000..59ec8c6e1ea --- /dev/null +++ b/db/migrate/20230509085428_change_organizations_sequence.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class ChangeOrganizationsSequence < Gitlab::Database::Migration[2.1] + def up + # Modify sequence for organizations.id so id '1' is never automatically taken + execute "ALTER SEQUENCE organizations_id_seq START WITH 1000 MINVALUE 1000 RESTART" + end + + def down + execute "ALTER SEQUENCE organizations_id_seq START WITH 1 MINVALUE 1" + end +end diff --git a/db/migrate/20230509115525_add_name_to_organization.rb b/db/migrate/20230509115525_add_name_to_organization.rb new file mode 100644 index 00000000000..d77fa84a70c --- /dev/null +++ b/db/migrate/20230509115525_add_name_to_organization.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# rubocop:disable Migration/AddLimitToTextColumns, Migration/AddIndex +# limit is added in 20230515111314_add_text_limit_on_organization_name.rb +class AddNameToOrganization < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'unique_organizations_on_name_lower' + + def up + add_column :organizations, :name, :text, null: false, default: '' + + add_index :organizations, 'lower(name)', name: INDEX_NAME, unique: true + end + + def down + remove_column :organizations, :name, if_exists: true + end +end +# rubocop:enable Migration/AddLimitToTextColumns, Migration/AddIndex diff --git a/db/migrate/20230509131736_add_default_organization.rb b/db/migrate/20230509131736_add_default_organization.rb new file mode 100644 index 00000000000..a63e7171f53 --- /dev/null +++ b/db/migrate/20230509131736_add_default_organization.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddDefaultOrganization < Gitlab::Database::Migration[2.1] + restrict_gitlab_migration gitlab_schema: :gitlab_main + + class Organization < MigrationRecord + end + + def up + Organization.create(id: 1, name: 'Default') + end + + def down + Organization.where(id: 1).delete_all + end +end diff --git a/db/migrate/20230515111314_add_text_limit_on_organization_name.rb b/db/migrate/20230515111314_add_text_limit_on_organization_name.rb new file mode 100644 index 00000000000..c0b687fab94 --- /dev/null +++ b/db/migrate/20230515111314_add_text_limit_on_organization_name.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddTextLimitOnOrganizationName < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + def up + add_text_limit :organizations, :name, 255 + end + + def down + remove_text_limit :organizations, :name + end +end diff --git a/db/schema_migrations/20230322164031 b/db/schema_migrations/20230322164031 new file mode 100644 index 00000000000..57478bae5b3 --- /dev/null +++ b/db/schema_migrations/20230322164031 @@ -0,0 +1 @@ +4610b001f48cc89d79a769231d73f7fe579ffe8753a276e32ddd4cc15ad5bf25
\ No newline at end of file diff --git a/db/schema_migrations/20230509085428 b/db/schema_migrations/20230509085428 new file mode 100644 index 00000000000..cf7214ceadc --- /dev/null +++ b/db/schema_migrations/20230509085428 @@ -0,0 +1 @@ +6179fe3d8c419c58e028fc1fe5d554678976229eff88f087beec174cb669d4ce
\ No newline at end of file diff --git a/db/schema_migrations/20230509115525 b/db/schema_migrations/20230509115525 new file mode 100644 index 00000000000..e3c0ada40cd --- /dev/null +++ b/db/schema_migrations/20230509115525 @@ -0,0 +1 @@ +92b70129d19796653569fb730be43ea6eed7dacbce224e1323124fdf03b0a0b0
\ No newline at end of file diff --git a/db/schema_migrations/20230509131736 b/db/schema_migrations/20230509131736 new file mode 100644 index 00000000000..593c9495eb2 --- /dev/null +++ b/db/schema_migrations/20230509131736 @@ -0,0 +1 @@ +f9545a27756e5ca05220ffebcf89e8268e0231cbd8c7af0a89d13c70f5a070ec
\ No newline at end of file diff --git a/db/schema_migrations/20230515111314 b/db/schema_migrations/20230515111314 new file mode 100644 index 00000000000..d2d7d2c94c4 --- /dev/null +++ b/db/schema_migrations/20230515111314 @@ -0,0 +1 @@ +2a011d12459e0c21832df777569a12f4f2bbdaa5f57da7dc3823147f948d7772
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 75087462e3a..8dea1331b6e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -15321,6 +15321,18 @@ CREATE SEQUENCE design_management_repositories_id_seq ALTER SEQUENCE design_management_repositories_id_seq OWNED BY design_management_repositories.id; +CREATE TABLE design_management_repository_states ( + verification_started_at timestamp with time zone, + verification_retry_at timestamp with time zone, + verified_at timestamp with time zone, + design_management_repository_id bigint NOT NULL, + verification_state smallint DEFAULT 0 NOT NULL, + verification_retry_count smallint DEFAULT 0 NOT NULL, + verification_checksum bytea, + verification_failure text, + CONSTRAINT check_bf1387c28b CHECK ((char_length(verification_failure) <= 255)) +); + CREATE TABLE design_management_versions ( id bigint NOT NULL, sha bytea NOT NULL, @@ -19179,13 +19191,15 @@ ALTER SEQUENCE operations_user_lists_id_seq OWNED BY operations_user_lists.id; CREATE TABLE organizations ( id bigint NOT NULL, created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL + updated_at timestamp with time zone NOT NULL, + name text DEFAULT ''::text NOT NULL, + CONSTRAINT check_d130d769e0 CHECK ((char_length(name) <= 255)) ); CREATE SEQUENCE organizations_id_seq - START WITH 1 + START WITH 1000 INCREMENT BY 1 - NO MINVALUE + MINVALUE 1000 NO MAXVALUE CACHE 1; @@ -27046,6 +27060,9 @@ ALTER TABLE ONLY design_management_designs_versions ALTER TABLE ONLY design_management_repositories ADD CONSTRAINT design_management_repositories_pkey PRIMARY KEY (id); +ALTER TABLE ONLY design_management_repository_states + ADD CONSTRAINT design_management_repository_states_pkey PRIMARY KEY (design_management_repository_id); + ALTER TABLE ONLY design_management_versions ADD CONSTRAINT design_management_versions_pkey PRIMARY KEY (id); @@ -30560,6 +30577,14 @@ CREATE INDEX index_design_management_designs_versions_on_version_id ON design_ma CREATE UNIQUE INDEX index_design_management_repositories_on_project_id ON design_management_repositories USING btree (project_id); +CREATE INDEX index_design_management_repository_states_failed_verification ON design_management_repository_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3); + +CREATE INDEX index_design_management_repository_states_needs_verification ON design_management_repository_states USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3)); + +CREATE INDEX index_design_management_repository_states_on_verification_state ON design_management_repository_states USING btree (verification_state); + +CREATE INDEX index_design_management_repository_states_pending_verification ON design_management_repository_states USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0); + CREATE INDEX index_design_management_versions_on_author_id ON design_management_versions USING btree (author_id) WHERE (author_id IS NOT NULL); CREATE INDEX index_design_management_versions_on_issue_id ON design_management_versions USING btree (issue_id); @@ -33170,6 +33195,8 @@ CREATE UNIQUE INDEX unique_index_on_system_note_metadata_id ON resource_link_eve CREATE UNIQUE INDEX unique_merge_request_metrics_by_merge_request_id ON merge_request_metrics USING btree (merge_request_id); +CREATE UNIQUE INDEX unique_organizations_on_name_lower ON organizations USING btree (lower(name)); + CREATE UNIQUE INDEX unique_packages_project_id_and_name_and_version_when_debian ON packages_packages USING btree (project_id, name, version) WHERE ((package_type = 9) AND (status <> 4)); CREATE UNIQUE INDEX unique_postgres_async_fk_validations_name_and_table_name ON postgres_async_foreign_key_validations USING btree (name, table_name); @@ -37021,6 +37048,9 @@ ALTER TABLE ONLY requirements_management_test_reports ALTER TABLE ONLY pool_repositories ADD CONSTRAINT fk_rails_d2711daad4 FOREIGN KEY (source_project_id) REFERENCES projects(id) ON DELETE SET NULL; +ALTER TABLE ONLY design_management_repository_states + ADD CONSTRAINT fk_rails_d2a258cc5a FOREIGN KEY (design_management_repository_id) REFERENCES design_management_repositories(id) ON DELETE CASCADE; + ALTER TABLE ONLY web_hooks ADD CONSTRAINT fk_rails_d35697648e FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE; |