diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-04 00:09:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-04 00:09:35 +0300 |
commit | e701659ba316541833e50d68f14720d17be58f8c (patch) | |
tree | 9e123fa2a749deaaf0a97612b05156576f55ff9f /db | |
parent | c2a6cc86754adb3c5e064cebc58d206a52cb412e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20201201161655_add_primary_key_to_elastic_search_indexed_projects.rb | 31 | ||||
-rw-r--r-- | db/migrate/20201201190002_add_other_context_to_experiment_user.rb | 19 | ||||
-rw-r--r-- | db/schema_migrations/20201201161655 | 1 | ||||
-rw-r--r-- | db/schema_migrations/20201201190002 | 1 | ||||
-rw-r--r-- | db/structure.sql | 10 |
5 files changed, 58 insertions, 4 deletions
diff --git a/db/migrate/20201201161655_add_primary_key_to_elastic_search_indexed_projects.rb b/db/migrate/20201201161655_add_primary_key_to_elastic_search_indexed_projects.rb new file mode 100644 index 00000000000..cf7221693f9 --- /dev/null +++ b/db/migrate/20201201161655_add_primary_key_to_elastic_search_indexed_projects.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +class AddPrimaryKeyToElasticSearchIndexedProjects < ActiveRecord::Migration[6.0] + DOWNTIME = false + + UNIQUE_INDEX_NAME = 'index_elasticsearch_indexed_projects_on_project_id' + PRIMARY_KEY_NAME = 'elasticsearch_indexed_projects_pkey' + + def up + execute(<<~SQL) + DELETE FROM elasticsearch_indexed_projects + WHERE project_id IS NULL + SQL + + execute(<<~SQL) + ALTER TABLE elasticsearch_indexed_projects + ALTER COLUMN project_id SET NOT NULL, + ADD CONSTRAINT #{PRIMARY_KEY_NAME} PRIMARY KEY USING INDEX #{UNIQUE_INDEX_NAME} + SQL + end + + def down + add_index :elasticsearch_indexed_projects, :project_id, unique: true, name: UNIQUE_INDEX_NAME # rubocop:disable Migration/AddIndex + + execute(<<~SQL) + ALTER TABLE elasticsearch_indexed_projects + DROP CONSTRAINT #{PRIMARY_KEY_NAME}, + ALTER COLUMN project_id DROP NOT NULL + SQL + end +end diff --git a/db/migrate/20201201190002_add_other_context_to_experiment_user.rb b/db/migrate/20201201190002_add_other_context_to_experiment_user.rb new file mode 100644 index 00000000000..c901f049e75 --- /dev/null +++ b/db/migrate/20201201190002_add_other_context_to_experiment_user.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddOtherContextToExperimentUser < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + add_column :experiment_users, :context, :jsonb, default: {}, null: false + end + end + + def down + with_lock_retries do + remove_column :experiment_users, :context + end + end +end diff --git a/db/schema_migrations/20201201161655 b/db/schema_migrations/20201201161655 new file mode 100644 index 00000000000..892d2bfc08d --- /dev/null +++ b/db/schema_migrations/20201201161655 @@ -0,0 +1 @@ +d9ad12dce02d6823536f3206e9c90a0da82c08089c3ce252e8ef28a59589e747
\ No newline at end of file diff --git a/db/schema_migrations/20201201190002 b/db/schema_migrations/20201201190002 new file mode 100644 index 00000000000..aac9ac34c64 --- /dev/null +++ b/db/schema_migrations/20201201190002 @@ -0,0 +1 @@ +f4ec800e68cbe092775b428d3ff85a4a84be0d55d70e59d23de390847ea3c2b7
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 94f92b2af16..9c53bb2de03 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -11935,7 +11935,7 @@ CREATE TABLE elasticsearch_indexed_namespaces ( CREATE TABLE elasticsearch_indexed_projects ( created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, - project_id integer + project_id integer NOT NULL ); CREATE TABLE emails ( @@ -12124,7 +12124,8 @@ CREATE TABLE experiment_users ( group_type smallint DEFAULT 0 NOT NULL, created_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL, - converted_at timestamp with time zone + converted_at timestamp with time zone, + context jsonb DEFAULT '{}'::jsonb NOT NULL ); CREATE SEQUENCE experiment_users_id_seq @@ -19255,6 +19256,9 @@ ALTER TABLE ONLY draft_notes ALTER TABLE ONLY elastic_reindexing_tasks ADD CONSTRAINT elastic_reindexing_tasks_pkey PRIMARY KEY (id); +ALTER TABLE ONLY elasticsearch_indexed_projects + ADD CONSTRAINT elasticsearch_indexed_projects_pkey PRIMARY KEY (project_id); + ALTER TABLE ONLY emails ADD CONSTRAINT emails_pkey PRIMARY KEY (id); @@ -21056,8 +21060,6 @@ CREATE INDEX index_elasticsearch_indexed_namespaces_on_created_at ON elasticsear CREATE UNIQUE INDEX index_elasticsearch_indexed_namespaces_on_namespace_id ON elasticsearch_indexed_namespaces USING btree (namespace_id); -CREATE UNIQUE INDEX index_elasticsearch_indexed_projects_on_project_id ON elasticsearch_indexed_projects USING btree (project_id); - CREATE UNIQUE INDEX index_emails_on_confirmation_token ON emails USING btree (confirmation_token); CREATE UNIQUE INDEX index_emails_on_email ON emails USING btree (email); |