diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 00:10:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 00:10:47 +0300 |
commit | 355a4a17ebbeb246e48954462163577ae77f45c0 (patch) | |
tree | 81aac8e172af511d87fcb9541508f69508bede84 /db | |
parent | 7488eeff6fdf82ee7b926d684a201212b0509cbb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/click_house/main/20230705124511_create_events.sql | 15 | ||||
-rw-r--r-- | db/docs/group_wiki_repository_states.yml | 10 | ||||
-rw-r--r-- | db/migrate/20230717200940_create_group_wiki_repository_states.rb | 43 | ||||
-rw-r--r-- | db/schema_migrations/20230717200940 | 1 | ||||
-rw-r--r-- | db/structure.sql | 40 |
5 files changed, 109 insertions, 0 deletions
diff --git a/db/click_house/main/20230705124511_create_events.sql b/db/click_house/main/20230705124511_create_events.sql new file mode 100644 index 00000000000..45e0139165a --- /dev/null +++ b/db/click_house/main/20230705124511_create_events.sql @@ -0,0 +1,15 @@ +CREATE TABLE events +( + id UInt64 DEFAULT 0, + path String DEFAULT '', + author_id UInt64 DEFAULT 0, + target_id UInt64 DEFAULT 0, + target_type LowCardinality(String) DEFAULT '', + action UInt8 DEFAULT 0, + created_at DateTime64(6, 'UTC') DEFAULT now(), + updated_at DateTime64(6, 'UTC') DEFAULT now() +) +ENGINE = ReplacingMergeTree(updated_at) +PRIMARY KEY (id) +ORDER BY (id) +PARTITION BY toYear(created_at) diff --git a/db/docs/group_wiki_repository_states.yml b/db/docs/group_wiki_repository_states.yml new file mode 100644 index 00000000000..574224173c9 --- /dev/null +++ b/db/docs/group_wiki_repository_states.yml @@ -0,0 +1,10 @@ +--- +table_name: group_wiki_repository_states +description: Separate table for group wiki verification states +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/126753 +milestone: '16.3' +feature_categories: +- geo_replication +classes: +- Geo::GroupWikiRepositoryState +gitlab_schema: gitlab_main diff --git a/db/migrate/20230717200940_create_group_wiki_repository_states.rb b/db/migrate/20230717200940_create_group_wiki_repository_states.rb new file mode 100644 index 00000000000..36b2173ab24 --- /dev/null +++ b/db/migrate/20230717200940_create_group_wiki_repository_states.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +class CreateGroupWikiRepositoryStates < Gitlab::Database::Migration[2.1] + VERIFICATION_STATE_INDEX_NAME = "index_group_wiki_repository_states_on_verification_state" + PENDING_VERIFICATION_INDEX_NAME = "index_group_wiki_repository_states_pending_verification" + FAILED_VERIFICATION_INDEX_NAME = "index_group_wiki_repository_states_failed_verification" + NEEDS_VERIFICATION_INDEX_NAME = "index_group_wiki_repository_states_needs_verification" + + enable_lock_retries! + + def up + create_table :group_wiki_repository_states do |t| + t.datetime_with_timezone :verification_started_at + t.datetime_with_timezone :verification_retry_at + t.datetime_with_timezone :verified_at + t.references :group_wiki_repository, + null: false, + index: { unique: true }, + foreign_key: { primary_key: :group_id, 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 :group_wiki_repository_states + end +end diff --git a/db/schema_migrations/20230717200940 b/db/schema_migrations/20230717200940 new file mode 100644 index 00000000000..6e25e66b8f8 --- /dev/null +++ b/db/schema_migrations/20230717200940 @@ -0,0 +1 @@ +970898c369a13483eab732969f1ef3a63f7bcaf041fdb8a2b8c10e93da0de7c1
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index b69f0da4a54..dcefc769996 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -16740,6 +16740,28 @@ CREATE TABLE group_wiki_repositories ( CONSTRAINT check_07f1c81806 CHECK ((char_length(disk_path) <= 80)) ); +CREATE TABLE group_wiki_repository_states ( + id bigint NOT NULL, + verification_started_at timestamp with time zone, + verification_retry_at timestamp with time zone, + verified_at timestamp with time zone, + group_wiki_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_14d288436d CHECK ((char_length(verification_failure) <= 255)) +); + +CREATE SEQUENCE group_wiki_repository_states_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER SEQUENCE group_wiki_repository_states_id_seq OWNED BY group_wiki_repository_states.id; + CREATE TABLE historical_data ( id integer NOT NULL, date date, @@ -25449,6 +25471,8 @@ ALTER TABLE ONLY group_import_states ALTER COLUMN group_id SET DEFAULT nextval(' ALTER TABLE ONLY group_repository_storage_moves ALTER COLUMN id SET DEFAULT nextval('group_repository_storage_moves_id_seq'::regclass); +ALTER TABLE ONLY group_wiki_repository_states ALTER COLUMN id SET DEFAULT nextval('group_wiki_repository_states_id_seq'::regclass); + ALTER TABLE ONLY historical_data ALTER COLUMN id SET DEFAULT nextval('historical_data_id_seq'::regclass); ALTER TABLE ONLY identities ALTER COLUMN id SET DEFAULT nextval('identities_id_seq'::regclass); @@ -27557,6 +27581,9 @@ ALTER TABLE ONLY group_repository_storage_moves ALTER TABLE ONLY group_wiki_repositories ADD CONSTRAINT group_wiki_repositories_pkey PRIMARY KEY (group_id); +ALTER TABLE ONLY group_wiki_repository_states + ADD CONSTRAINT group_wiki_repository_states_pkey PRIMARY KEY (id); + ALTER TABLE ONLY historical_data ADD CONSTRAINT historical_data_pkey PRIMARY KEY (id); @@ -31420,6 +31447,16 @@ CREATE UNIQUE INDEX index_group_wiki_repositories_on_disk_path ON group_wiki_rep CREATE INDEX index_group_wiki_repositories_on_shard_id ON group_wiki_repositories USING btree (shard_id); +CREATE INDEX index_group_wiki_repository_states_failed_verification ON group_wiki_repository_states USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3); + +CREATE INDEX index_group_wiki_repository_states_needs_verification ON group_wiki_repository_states USING btree (verification_state) WHERE ((verification_state = 0) OR (verification_state = 3)); + +CREATE UNIQUE INDEX index_group_wiki_repository_states_on_group_wiki_repository_id ON group_wiki_repository_states USING btree (group_wiki_repository_id); + +CREATE INDEX index_group_wiki_repository_states_on_verification_state ON group_wiki_repository_states USING btree (verification_state); + +CREATE INDEX index_group_wiki_repository_states_pending_verification ON group_wiki_repository_states USING btree (verified_at NULLS FIRST) WHERE (verification_state = 0); + CREATE INDEX index_groups_on_parent_id_id ON namespaces USING btree (parent_id, id) WHERE ((type)::text = 'Group'::text); CREATE INDEX index_groups_on_path_and_id ON namespaces USING btree (path, id) WHERE ((type)::text = 'Group'::text); @@ -37288,6 +37325,9 @@ ALTER TABLE ONLY required_code_owners_sections ALTER TABLE ONLY namespace_ldap_settings ADD CONSTRAINT fk_rails_82cd0ad4bb FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; +ALTER TABLE ONLY group_wiki_repository_states + ADD CONSTRAINT fk_rails_832511c9f1 FOREIGN KEY (group_wiki_repository_id) REFERENCES group_wiki_repositories(group_id) ON DELETE CASCADE; + ALTER TABLE ONLY cluster_enabled_grants ADD CONSTRAINT fk_rails_8336ce35af FOREIGN KEY (namespace_id) REFERENCES namespaces(id) ON DELETE CASCADE; |