From f1a74a656bcede06d082e351d6261e43a88a0df7 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 15 Nov 2018 15:17:32 +0100 Subject: Encrypt new instance runners registration tokens --- .../20181115140140_add_encrypted_runners_token_to_settings.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb (limited to 'db/migrate') diff --git a/db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb b/db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb new file mode 100644 index 00000000000..36d9ad45b19 --- /dev/null +++ b/db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddEncryptedRunnersTokenToSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :application_settings, :runners_registration_token_encrypted, :string + end +end -- cgit v1.2.1 From fa33a2eedc4014ffbc450a74fcd112e663ac5b01 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 16 Nov 2018 15:16:37 +0100 Subject: Encrypt group / project runners registration tokens --- ...181116141415_add_encrypted_runners_token_to_namespaces.rb | 12 ++++++++++++ ...20181116141504_add_encrypted_runners_token_to_projects.rb | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb create mode 100644 db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb (limited to 'db/migrate') diff --git a/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb b/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb new file mode 100644 index 00000000000..a5a6373dd38 --- /dev/null +++ b/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :namespaces, :runners_token_encrypted, :string + # TODO index + end +end diff --git a/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb b/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb new file mode 100644 index 00000000000..32401629478 --- /dev/null +++ b/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :projects, :runners_token_encrypted, :string + # TODO index + end +end -- cgit v1.2.1 From e491df5fc67a51d78e8d832a4919aff0033dc0bd Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 20 Nov 2018 16:30:39 +0100 Subject: Encrypt runners communication token in the database --- .../20181120151656_add_token_encrypted_to_ci_runners.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb (limited to 'db/migrate') diff --git a/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb b/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb new file mode 100644 index 00000000000..8a9df4b44f8 --- /dev/null +++ b/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddTokenEncryptedToCiRunners < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_runners, :token_encrypted, :string + # TODO index + end +end -- cgit v1.2.1 From 3578eb45f940ed3ddab742538bd1910b0bd8834f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 21 Nov 2018 11:28:06 +0100 Subject: Add database indices to encrypted runner tokens --- ...415_add_encrypted_runners_token_to_namespaces.rb | 1 - ...41504_add_encrypted_runners_token_to_projects.rb | 1 - ...81120151656_add_token_encrypted_to_ci_runners.rb | 1 - ...121101802_add_encrypted_runner_tokens_indices.rb | 21 +++++++++++++++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb (limited to 'db/migrate') diff --git a/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb b/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb index a5a6373dd38..b92b1b50218 100644 --- a/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb +++ b/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb @@ -7,6 +7,5 @@ class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration def change add_column :namespaces, :runners_token_encrypted, :string - # TODO index end end diff --git a/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb b/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb index 32401629478..53e475bd180 100644 --- a/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb +++ b/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb @@ -7,6 +7,5 @@ class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration def change add_column :projects, :runners_token_encrypted, :string - # TODO index end end diff --git a/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb b/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb index 8a9df4b44f8..40db6b399ab 100644 --- a/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb +++ b/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb @@ -7,6 +7,5 @@ class AddTokenEncryptedToCiRunners < ActiveRecord::Migration def change add_column :ci_runners, :token_encrypted, :string - # TODO index end end diff --git a/db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb b/db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb new file mode 100644 index 00000000000..a4da24501a3 --- /dev/null +++ b/db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddEncryptedRunnerTokensIndices < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :namespaces, :runners_token_encrypted, unique: true + add_concurrent_index :projects, :runners_token_encrypted, unique: true + add_concurrent_index :ci_runners, :token_encrypted, unique: true + end + + def down + remove_concurrent_index :ci_runners, :token_encrypted + remove_concurrent_index :projects, :runners_token_encrypted + remove_concurrent_index :namespaces, :runners_token_encrypted + end +end -- cgit v1.2.1 From fff7754186202cfcdeaa0962c28e5d43ddd705b7 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Tue, 20 Nov 2018 12:48:18 +0100 Subject: Rename the Repository table to PoolRepository To separate the different kinds of repositories we have at GitLab this table will be renamed to pool_repositories. A project can, for now at least, be member of none, or one of these. The table will get additional columns in a later merge request where more logic is implemented for the model. Further included is a small refactor of logic around hashing ids for the disk_path, mainly to ensure a previous implementation is reusable. The disk_path for the pool_repositories table no longer has a NOT NULL constraint, but given the hashing of the ID requires the DB to assign the record an ID, an after_create hook is used to update the value. A related MR is: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23143, adding tables for 'normal' repositories and wiki_repositories. --- .../20181120082911_rename_repositories_pool_repositories.rb | 11 +++++++++++ ...5036_drop_not_null_constraint_pool_repository_disk_path.rb | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 db/migrate/20181120082911_rename_repositories_pool_repositories.rb create mode 100644 db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb (limited to 'db/migrate') diff --git a/db/migrate/20181120082911_rename_repositories_pool_repositories.rb b/db/migrate/20181120082911_rename_repositories_pool_repositories.rb new file mode 100644 index 00000000000..165771c4775 --- /dev/null +++ b/db/migrate/20181120082911_rename_repositories_pool_repositories.rb @@ -0,0 +1,11 @@ +class RenameRepositoriesPoolRepositories < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # This change doesn't require downtime as the table is not in use, so we're + # free to change an empty table + DOWNTIME = false + + def change + rename_table :repositories, :pool_repositories + end +end diff --git a/db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb b/db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb new file mode 100644 index 00000000000..bcd969e91c5 --- /dev/null +++ b/db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class DropNotNullConstraintPoolRepositoryDiskPath < ActiveRecord::Migration[5.0] + DOWNTIME = false + + def change + change_column_null :pool_repositories, :disk_path, true + end +end -- cgit v1.2.1 From 4bc6f2e3ac8e6997ebc3b06867049dc38aa6d6e6 Mon Sep 17 00:00:00 2001 From: Cindy Pallares Date: Wed, 28 Nov 2018 18:37:12 +0000 Subject: Merge branch 'security-stored-xss-for-environments' into 'master' [master] Stored XSS for Environments Closes #2727 See merge request gitlab/gitlabhq!2594 --- ...20181108091549_cleanup_environments_external_url.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/migrate/20181108091549_cleanup_environments_external_url.rb (limited to 'db/migrate') diff --git a/db/migrate/20181108091549_cleanup_environments_external_url.rb b/db/migrate/20181108091549_cleanup_environments_external_url.rb new file mode 100644 index 00000000000..8d6c20a4b15 --- /dev/null +++ b/db/migrate/20181108091549_cleanup_environments_external_url.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CleanupEnvironmentsExternalUrl < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + update_column_in_batches(:environments, :external_url, nil) do |table, query| + query.where(table[:external_url].matches('javascript://%')) + end + end + + def down + end +end -- cgit v1.2.1 From 198fdc54789dcb24efb0622a23e6931d83e1faa6 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Thu, 29 Nov 2018 16:08:14 +0000 Subject: Store hashed storage paths in the database --- .../20181122160027_create_project_repositories.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/migrate/20181122160027_create_project_repositories.rb (limited to 'db/migrate') diff --git a/db/migrate/20181122160027_create_project_repositories.rb b/db/migrate/20181122160027_create_project_repositories.rb new file mode 100644 index 00000000000..e42cef9b1c6 --- /dev/null +++ b/db/migrate/20181122160027_create_project_repositories.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateProjectRepositories < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :project_repositories, id: :bigserial do |t| + t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict } + t.string :disk_path, null: false, index: { unique: true } + t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } + end + end +end -- cgit v1.2.1 From 6cd2c0a7ec22ebf6da4ec372e13bd2921543d8a3 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Thu, 29 Nov 2018 18:47:25 +0100 Subject: Move drop_site_statistics to be a post deployment migration As post deployment migration we don't need to make it a migration that requires downtime --- db/migrate/20181123042307_drop_site_statistics.rb | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 db/migrate/20181123042307_drop_site_statistics.rb (limited to 'db/migrate') diff --git a/db/migrate/20181123042307_drop_site_statistics.rb b/db/migrate/20181123042307_drop_site_statistics.rb deleted file mode 100644 index 8986374ef65..00000000000 --- a/db/migrate/20181123042307_drop_site_statistics.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class DropSiteStatistics < ActiveRecord::Migration[5.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - drop_table :site_statistics - end - - def down - create_table :site_statistics do |t| - t.integer :repositories_count, default: 0, null: false - end - - execute('INSERT INTO site_statistics (id) VALUES(1)') - end -end -- cgit v1.2.1 From 143b80bb37d9534ec0b48900d3ab3287c58f68f0 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 3 Dec 2018 13:22:24 +0100 Subject: Do not add indices for encrypted tokens in this iteration --- ...121101802_add_encrypted_runner_tokens_indices.rb | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb (limited to 'db/migrate') diff --git a/db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb b/db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb deleted file mode 100644 index a4da24501a3..00000000000 --- a/db/migrate/20181121101802_add_encrypted_runner_tokens_indices.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -class AddEncryptedRunnerTokensIndices < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :namespaces, :runners_token_encrypted, unique: true - add_concurrent_index :projects, :runners_token_encrypted, unique: true - add_concurrent_index :ci_runners, :token_encrypted, unique: true - end - - def down - remove_concurrent_index :ci_runners, :token_encrypted - remove_concurrent_index :projects, :runners_token_encrypted - remove_concurrent_index :namespaces, :runners_token_encrypted - end -end -- cgit v1.2.1 From 5733f5b875308ba848753e4ada81f8a4a633a7b7 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 21 Nov 2018 10:25:55 +0000 Subject: Add partial index for ci_builds on project_id and status --- ...uilds_partial_index_on_project_id_and_status.rb | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb (limited to 'db/migrate') diff --git a/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb new file mode 100644 index 00000000000..5b47a279438 --- /dev/null +++ b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddCiBuildsPartialIndexOnProjectIdAndStatus < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index(*index_arguments) + end + + def down + remove_concurrent_index(*index_arguments) + end + + private + + def index_arguments + [ + :ci_builds, + [:project_id, :status], + { + name: 'index_ci_builds_project_id_and_status_for_live_jobs_partial2', + where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))" + } + ] + end +end -- cgit v1.2.1 From abf3c9680e132af49662f3600dc601b2d995b81c Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 3 Dec 2018 23:20:28 +0800 Subject: Remove redundant ci_builds partial index on GitLab.com --- ...843_remove_redundant_ci_builds_partial_index.rb | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb (limited to 'db/migrate') diff --git a/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb new file mode 100644 index 00000000000..a0a02e81323 --- /dev/null +++ b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RemoveRedundantCiBuildsPartialIndex < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + remove_concurrent_index(*index_arguments) + end + + def down + add_concurrent_index(*index_arguments) + end + + private + + def index_arguments + [ + :ci_builds, + [:project_id, :status], + { + name: 'index_ci_builds_project_id_and_status_for_live_jobs_partial', + where: "((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text]))" + } + ] + end +end -- cgit v1.2.1 From e62bfc7817ec024645383a9661fe7e36c13c1e01 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 5 Dec 2018 15:57:00 +0900 Subject: Merge request pipelines --- ...9081539_add_merge_request_id_to_ci_pipelines.rb | 13 +++++++++++++ ...d_foreign_key_to_ci_pipelines_merge_requests.rb | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb create mode 100644 db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb (limited to 'db/migrate') diff --git a/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb b/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb new file mode 100644 index 00000000000..65476109c61 --- /dev/null +++ b/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddMergeRequestIdToCiPipelines < ActiveRecord::Migration + DOWNTIME = false + + def up + add_column :ci_pipelines, :merge_request_id, :integer + end + + def down + remove_column :ci_pipelines, :merge_request_id, :integer + end +end diff --git a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb new file mode 100644 index 00000000000..c2b5b239279 --- /dev/null +++ b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_pipelines, :merge_request_id + add_concurrent_foreign_key :ci_pipelines, :merge_requests, column: :merge_request_id, on_delete: :cascade + end + + def down + if foreign_key_exists?(:ci_pipelines, :merge_requests, column: :merge_request_id) + remove_foreign_key :ci_pipelines, :merge_requests + end + + remove_concurrent_index :ci_pipelines, :merge_request_id + end +end -- cgit v1.2.1 From 03f4ad4323bed8bc04ad3d93a50e187e6677281e Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 29 Nov 2018 11:54:35 +0100 Subject: Add encrypted token field to ci_builds table --- .../20181129104854_add_token_encrypted_to_ci_builds.rb | 11 +++++++++++ ...1129104944_add_index_to_ci_builds_token_encrypted.rb | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb create mode 100644 db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb (limited to 'db/migrate') diff --git a/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb b/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb new file mode 100644 index 00000000000..11b98203793 --- /dev/null +++ b/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddTokenEncryptedToCiBuilds < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_builds, :token_encrypted, :string + end +end diff --git a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb new file mode 100644 index 00000000000..198d94fa7be --- /dev/null +++ b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexToCiBuildsTokenEncrypted < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_builds, :token_encrypted, unique: true + end + + def down + remove_concurrent_index :ci_builds, :token_encrypted + end +end -- cgit v1.2.1 From 73f872448b59600eca792f9a34e2c8bfa976afde Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 5 Dec 2018 15:15:25 +0100 Subject: Use partial NOT NULL index for token_encrypted field --- db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db/migrate') diff --git a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb index 198d94fa7be..f90aca008e5 100644 --- a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb +++ b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb @@ -8,7 +8,7 @@ class AddIndexToCiBuildsTokenEncrypted < ActiveRecord::Migration[5.0] disable_ddl_transaction! def up - add_concurrent_index :ci_builds, :token_encrypted, unique: true + add_concurrent_index :ci_builds, :token_encrypted, unique: true, where: 'token_encrypted IS NOT NULL' end def down -- cgit v1.2.1 From 0e8b9c4a1ecbd3e52ba379494872e019ec7edfe1 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 6 Dec 2018 16:05:26 +0900 Subject: Change to partial index --- .../20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db/migrate') diff --git a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb index c2b5b239279..03f677a4678 100644 --- a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb +++ b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb @@ -8,7 +8,7 @@ class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration disable_ddl_transaction! def up - add_concurrent_index :ci_pipelines, :merge_request_id + add_concurrent_index :ci_pipelines, :merge_request_id, where: 'merge_request_id IS NOT NULL' add_concurrent_foreign_key :ci_pipelines, :merge_requests, column: :merge_request_id, on_delete: :cascade end @@ -17,6 +17,6 @@ class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration remove_foreign_key :ci_pipelines, :merge_requests end - remove_concurrent_index :ci_pipelines, :merge_request_id + remove_concurrent_index :ci_pipelines, :merge_request_id, where: 'merge_request_id IS NOT NULL' end end -- cgit v1.2.1 From 9395d198f9b9ec59858d2f316e58cda22ab80050 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Mon, 19 Nov 2018 15:03:58 +0000 Subject: Use BFG object maps to clean projects --- db/migrate/20181203002526_add_project_bfg_object_map_column.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20181203002526_add_project_bfg_object_map_column.rb (limited to 'db/migrate') diff --git a/db/migrate/20181203002526_add_project_bfg_object_map_column.rb b/db/migrate/20181203002526_add_project_bfg_object_map_column.rb new file mode 100644 index 00000000000..8b42cd6f941 --- /dev/null +++ b/db/migrate/20181203002526_add_project_bfg_object_map_column.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddProjectBfgObjectMapColumn < ActiveRecord::Migration[5.0] + DOWNTIME = false + + def change + add_column :projects, :bfg_object_map, :string + end +end -- cgit v1.2.1 From 950b9130adcb4d2fa45bd1757c1b3dc50f1df9a4 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 6 Dec 2018 18:53:24 -0600 Subject: Revert "Merge branch 'fix/gb/encrypt-ci-build-token' into 'master'" This reverts commit 1e8f1de034aa9b6a60b640b2b091f60c4d3ba365, reversing changes made to 62d971129da99936a3cdc04f3740d26f16a0c7a6. --- .../20181129104854_add_token_encrypted_to_ci_builds.rb | 11 ----------- ...1129104944_add_index_to_ci_builds_token_encrypted.rb | 17 ----------------- 2 files changed, 28 deletions(-) delete mode 100644 db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb delete mode 100644 db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb (limited to 'db/migrate') diff --git a/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb b/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb deleted file mode 100644 index 11b98203793..00000000000 --- a/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class AddTokenEncryptedToCiBuilds < ActiveRecord::Migration[5.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_builds, :token_encrypted, :string - end -end diff --git a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb deleted file mode 100644 index f90aca008e5..00000000000 --- a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -class AddIndexToCiBuildsTokenEncrypted < ActiveRecord::Migration[5.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :ci_builds, :token_encrypted, unique: true, where: 'token_encrypted IS NOT NULL' - end - - def down - remove_concurrent_index :ci_builds, :token_encrypted - end -end -- cgit v1.2.1 From a910c09bbc8c56002db10d669e4ae1e4bdef9f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 6 Dec 2018 09:42:18 +0000 Subject: Encrypt CI/CD builds tokens Brings back 1e8f1de0 reverted in !23644 Closes #52342 See merge request gitlab-org/gitlab-ce!23436 --- .../20181129104854_add_token_encrypted_to_ci_builds.rb | 11 +++++++++++ ...1129104944_add_index_to_ci_builds_token_encrypted.rb | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb create mode 100644 db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb (limited to 'db/migrate') diff --git a/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb b/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb new file mode 100644 index 00000000000..11b98203793 --- /dev/null +++ b/db/migrate/20181129104854_add_token_encrypted_to_ci_builds.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddTokenEncryptedToCiBuilds < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_builds, :token_encrypted, :string + end +end diff --git a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb new file mode 100644 index 00000000000..f90aca008e5 --- /dev/null +++ b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddIndexToCiBuildsTokenEncrypted < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_builds, :token_encrypted, unique: true, where: 'token_encrypted IS NOT NULL' + end + + def down + remove_concurrent_index :ci_builds, :token_encrypted + end +end -- cgit v1.2.1 From 896c0bdbfb1a83ff5a7d0a755ac249ac2a895798 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Mon, 3 Dec 2018 14:49:58 +0100 Subject: Allow public forks to be deduplicated When a project is forked, the new repository used to be a deep copy of everything stored on disk by leveraging `git clone`. This works well, and makes isolation between repository easy. However, the clone is at the start 100% the same as the origin repository. And in the case of the objects in the object directory, this is almost always going to be a lot of duplication. Object Pools are a way to create a third repository that essentially only exists for its 'objects' subdirectory. This third repository's object directory will be set as alternate location for objects. This means that in the case an object is missing in the local repository, git will look in another location. This other location is the object pool repository. When Git performs garbage collection, it's smart enough to check the alternate location. When objects are duplicated, it will allow git to throw one copy away. This copy is on the local repository, where to pool remains as is. These pools have an origin location, which for now will always be a repository that itself is not a fork. When the root of a fork network is forked by a user, the fork still clones the full repository. Async, the pool repository will be created. Either one of these processes can be done earlier than the other. To handle this race condition, the Join ObjectPool operation is idempotent. Given its idempotent, we can schedule it twice, with the same effect. To accommodate the holding of state two migrations have been added. 1. Added a state column to the pool_repositories column. This column is managed by the state machine, allowing for hooks on transitions. 2. pool_repositories now has a source_project_id. This column in convenient to have for multiple reasons: it has a unique index allowing the database to handle race conditions when creating a new record. Also, it's nice to know who the host is. As that's a short link to the fork networks root. Object pools are only available for public project, which use hashed storage and when forking from the root of the fork network. (That is, the project being forked from itself isn't a fork) In this commit message I use both ObjectPool and Pool repositories, which are alike, but different from each other. ObjectPool refers to whatever is on the disk stored and managed by Gitaly. PoolRepository is the record in the database. --- .../20181128123704_add_state_to_pool_repository.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 db/migrate/20181128123704_add_state_to_pool_repository.rb (limited to 'db/migrate') diff --git a/db/migrate/20181128123704_add_state_to_pool_repository.rb b/db/migrate/20181128123704_add_state_to_pool_repository.rb new file mode 100644 index 00000000000..714232ede56 --- /dev/null +++ b/db/migrate/20181128123704_add_state_to_pool_repository.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddStateToPoolRepository < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + # Given the table is empty, and the non concurrent methods are chosen so + # the transactions don't have to be disabled + # rubocop: disable Migration/AddConcurrentForeignKey, Migration/AddIndex + def change + add_column(:pool_repositories, :state, :string, null: true) + + add_column :pool_repositories, :source_project_id, :integer + add_index :pool_repositories, :source_project_id, unique: true + add_foreign_key :pool_repositories, :projects, column: :source_project_id, on_delete: :nullify + end + # rubocop: enable Migration/AddConcurrentForeignKey, Migration/AddIndex +end -- cgit v1.2.1 From 40ad7d5d7a01a6f019ce1c3bb8864b16fc48e9c8 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 12 Dec 2018 16:38:40 +0100 Subject: Fix ActiveRecord::Migration deprecations Extending from ActiveRecord::Migration is deprecated, but was still used in a bunch of places. --- db/migrate/20181101191341_create_clusters_applications_cert_manager.rb | 2 +- db/migrate/20181108091549_cleanup_environments_external_url.rb | 2 +- db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb | 2 +- db/migrate/20181116050532_knative_external_ip.rb | 2 +- db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb | 2 +- db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb | 2 +- db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb | 2 +- .../20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb | 2 +- db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb | 2 +- ...181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb | 2 +- db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'db/migrate') diff --git a/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb b/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb index 4966b89964a..0b6155356d9 100644 --- a/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb +++ b/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateClustersApplicationsCertManager < ActiveRecord::Migration +class CreateClustersApplicationsCertManager < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181108091549_cleanup_environments_external_url.rb b/db/migrate/20181108091549_cleanup_environments_external_url.rb index 8d6c20a4b15..8439f6e55e6 100644 --- a/db/migrate/20181108091549_cleanup_environments_external_url.rb +++ b/db/migrate/20181108091549_cleanup_environments_external_url.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CleanupEnvironmentsExternalUrl < ActiveRecord::Migration +class CleanupEnvironmentsExternalUrl < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb b/db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb index 36d9ad45b19..5b2bb4f6b08 100644 --- a/db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb +++ b/db/migrate/20181115140140_add_encrypted_runners_token_to_settings.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddEncryptedRunnersTokenToSettings < ActiveRecord::Migration +class AddEncryptedRunnersTokenToSettings < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181116050532_knative_external_ip.rb b/db/migrate/20181116050532_knative_external_ip.rb index f1f903fb692..5645b040a23 100644 --- a/db/migrate/20181116050532_knative_external_ip.rb +++ b/db/migrate/20181116050532_knative_external_ip.rb @@ -3,7 +3,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -class KnativeExternalIp < ActiveRecord::Migration +class KnativeExternalIp < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb b/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb index b92b1b50218..dcf565cd6c0 100644 --- a/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb +++ b/db/migrate/20181116141415_add_encrypted_runners_token_to_namespaces.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration +class AddEncryptedRunnersTokenToNamespaces < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb b/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb index 53e475bd180..13cd80e5c8b 100644 --- a/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb +++ b/db/migrate/20181116141504_add_encrypted_runners_token_to_projects.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration +class AddEncryptedRunnersTokenToProjects < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb b/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb index 65476109c61..f96d80787f9 100644 --- a/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb +++ b/db/migrate/20181119081539_add_merge_request_id_to_ci_pipelines.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddMergeRequestIdToCiPipelines < ActiveRecord::Migration +class AddMergeRequestIdToCiPipelines < ActiveRecord::Migration[4.2] DOWNTIME = false def up diff --git a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb index 03f677a4678..f8b46395941 100644 --- a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb +++ b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration +class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb b/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb index 40db6b399ab..8b990451adc 100644 --- a/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb +++ b/db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddTokenEncryptedToCiRunners < ActiveRecord::Migration +class AddTokenEncryptedToCiRunners < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb index 5b47a279438..a524709faf8 100644 --- a/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb +++ b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb @@ -3,7 +3,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -class AddCiBuildsPartialIndexOnProjectIdAndStatus < ActiveRecord::Migration +class AddCiBuildsPartialIndexOnProjectIdAndStatus < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb index a0a02e81323..e4fb703e887 100644 --- a/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb +++ b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb @@ -3,7 +3,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -class RemoveRedundantCiBuildsPartialIndex < ActiveRecord::Migration +class RemoveRedundantCiBuildsPartialIndex < ActiveRecord::Migration[4.2] include Gitlab::Database::MigrationHelpers DOWNTIME = false -- cgit v1.2.1 From b782ba1113970728989eebdf4c8fc44f8091c8d8 Mon Sep 17 00:00:00 2001 From: Alessio Caiazza Date: Wed, 12 Dec 2018 10:56:43 +0100 Subject: Add name, author and sha to releases This commit adds a name to each release, defaulting it to tag name, keeps track of the SHA when a new release is created and tracks the current user as release author. --- ...092510_add_name_author_id_and_sha_to_releases.rb | 13 +++++++++++++ ...092514_add_author_id_index_and_fk_to_releases.rb | 21 +++++++++++++++++++++ ...12104941_backfill_releases_name_with_tag_name.rb | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 db/migrate/20181211092510_add_name_author_id_and_sha_to_releases.rb create mode 100644 db/migrate/20181211092514_add_author_id_index_and_fk_to_releases.rb create mode 100644 db/migrate/20181212104941_backfill_releases_name_with_tag_name.rb (limited to 'db/migrate') diff --git a/db/migrate/20181211092510_add_name_author_id_and_sha_to_releases.rb b/db/migrate/20181211092510_add_name_author_id_and_sha_to_releases.rb new file mode 100644 index 00000000000..60815e0c31a --- /dev/null +++ b/db/migrate/20181211092510_add_name_author_id_and_sha_to_releases.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddNameAuthorIdAndShaToReleases < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :releases, :author_id, :integer + add_column :releases, :name, :string + add_column :releases, :sha, :string + end +end diff --git a/db/migrate/20181211092514_add_author_id_index_and_fk_to_releases.rb b/db/migrate/20181211092514_add_author_id_index_and_fk_to_releases.rb new file mode 100644 index 00000000000..f6350a49944 --- /dev/null +++ b/db/migrate/20181211092514_add_author_id_index_and_fk_to_releases.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddAuthorIdIndexAndFkToReleases < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :releases, :author_id + + add_concurrent_foreign_key :releases, :users, column: :author_id, on_delete: :nullify + end + + def down + remove_foreign_key :releases, column: :author_id + + remove_concurrent_index :releases, column: :author_id + end +end diff --git a/db/migrate/20181212104941_backfill_releases_name_with_tag_name.rb b/db/migrate/20181212104941_backfill_releases_name_with_tag_name.rb new file mode 100644 index 00000000000..e152dc87bc1 --- /dev/null +++ b/db/migrate/20181212104941_backfill_releases_name_with_tag_name.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class BackfillReleasesNameWithTagName < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + update_column_in_batches(:releases, :name, Release.arel_table[:tag]) + end + + def down + # no-op + end +end -- cgit v1.2.1 From ed3034bbb71d43b12944a9da29b5264cb3ff3312 Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Thu, 13 Dec 2018 19:17:19 +0000 Subject: Allow suggesting single line changes in diffs --- db/migrate/20181123144235_create_suggestions.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 db/migrate/20181123144235_create_suggestions.rb (limited to 'db/migrate') diff --git a/db/migrate/20181123144235_create_suggestions.rb b/db/migrate/20181123144235_create_suggestions.rb new file mode 100644 index 00000000000..bcc4d8c538b --- /dev/null +++ b/db/migrate/20181123144235_create_suggestions.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class CreateSuggestions < ActiveRecord::Migration + DOWNTIME = false + + def change + create_table :suggestions, id: :bigserial do |t| + t.references :note, foreign_key: { on_delete: :cascade }, null: false + t.integer :relative_order, null: false, limit: 2 + t.boolean :applied, null: false, default: false + t.string :commit_id + t.text :from_content, null: false + t.text :to_content, null: false + + t.index [:note_id, :relative_order], + name: 'index_suggestions_on_note_id_and_relative_order', + unique: true + end + end +end -- cgit v1.2.1 From 56296f1edadf2bc5f7741cbb3f97cb41f090aac6 Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Sat, 15 Dec 2018 10:06:56 +0100 Subject: Remove rails4 specific code --- db/migrate/20160226114608_add_trigram_indexes_for_searching.rb | 7 +------ db/migrate/20161207231620_fixup_environment_name_uniqueness.rb | 3 +-- db/migrate/20161207231626_add_environment_slug.rb | 3 +-- 3 files changed, 3 insertions(+), 10 deletions(-) (limited to 'db/migrate') diff --git a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb b/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb index 82b54c552e0..af8b08c095a 100644 --- a/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb +++ b/db/migrate/20160226114608_add_trigram_indexes_for_searching.rb @@ -37,12 +37,7 @@ class AddTrigramIndexesForSearching < ActiveRecord::Migration[4.2] res = execute("SELECT true AS enabled FROM pg_available_extensions WHERE name = 'pg_trgm' AND installed_version IS NOT NULL;") row = res.first - check = if Gitlab.rails5? - true - else - 't' - end - row && row['enabled'] == check ? true : false + row && row['enabled'] == true end def create_trigrams_extension diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index 7cae09021cd..420f0ccb45c 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -1,5 +1,4 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration[4.2] - include Gitlab::Database::ArelMethods include Gitlab::Database::MigrationHelpers DOWNTIME = true @@ -42,7 +41,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration[4.2] conflicts.each do |id, name| update_sql = - arel_update_manager + Arel::UpdateManager.new .table(environments) .set(environments[:name] => name + "-" + id.to_s) .where(environments[:id].eq(id)) diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 4657b023dfa..993b9bd3330 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -2,7 +2,6 @@ # for more information on how to write migrations for GitLab. class AddEnvironmentSlug < ActiveRecord::Migration[4.2] - include Gitlab::Database::ArelMethods include Gitlab::Database::MigrationHelpers DOWNTIME = true @@ -20,7 +19,7 @@ class AddEnvironmentSlug < ActiveRecord::Migration[4.2] finder = environments.project(:id, :name) connection.exec_query(finder.to_sql).rows.each do |id, name| - updater = arel_update_manager + updater = Arel::UpdateManager.new .table(environments) .set(environments[:slug] => generate_slug(name)) .where(environments[:id].eq(id)) -- cgit v1.2.1 From b9e67b7f3bda09e929f65901c78d9159600949fa Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Mon, 17 Dec 2018 18:37:32 +0100 Subject: Fix deprecation: Directly inheriting from ActiveRecord::Migration is deprecated. --- db/migrate/20181123144235_create_suggestions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db/migrate') diff --git a/db/migrate/20181123144235_create_suggestions.rb b/db/migrate/20181123144235_create_suggestions.rb index bcc4d8c538b..1723f6de7eb 100644 --- a/db/migrate/20181123144235_create_suggestions.rb +++ b/db/migrate/20181123144235_create_suggestions.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateSuggestions < ActiveRecord::Migration +class CreateSuggestions < ActiveRecord::Migration[5.0] DOWNTIME = false def change -- cgit v1.2.1 From 3b9ab3f50f9286d0aae88f57708f97121597a64b Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Mon, 17 Dec 2018 23:48:55 +0000 Subject: Add NGINX 0.16.0 and above metrics --- .../20181006004100_import_common_metrics_nginx_vts.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/migrate/20181006004100_import_common_metrics_nginx_vts.rb (limited to 'db/migrate') diff --git a/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb new file mode 100644 index 00000000000..98fafed7912 --- /dev/null +++ b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb @@ -0,0 +1,15 @@ +class ImportCommonMetricsNginxVts < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + require Rails.root.join('db/importers/common_metrics_importer.rb') + + DOWNTIME = false + + def up + Importers::CommonMetricsImporter.new.execute + end + + def down + # no-op + end +end -- cgit v1.2.1 From f63f165a1f01dd3f4ae23b6fd85828b4b038ff9d Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Tue, 18 Dec 2018 17:14:42 +0100 Subject: ActiveRecord::Migration -> ActiveRecord::Migration[5.0] --- db/migrate/20181006004100_import_common_metrics_nginx_vts.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db/migrate') diff --git a/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb index 98fafed7912..5cd312837df 100644 --- a/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb +++ b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb @@ -1,4 +1,4 @@ -class ImportCommonMetricsNginxVts < ActiveRecord::Migration +class ImportCommonMetricsNginxVts < ActiveRecord::Migration[5.0] include Gitlab::Database::MigrationHelpers require Rails.root.join('db/importers/common_metrics_importer.rb') -- cgit v1.2.1