From 6d92a3d4e232d4137f66773c82f01c32d7474a21 Mon Sep 17 00:00:00 2001 From: Imre Farkas Date: Wed, 20 Feb 2019 11:39:37 +0000 Subject: Remove undigested token column from personal_access_tokens table Token column are no longer used as token values are stored digested in token_digest. --- db/post_migrate/20181101091005_steal_digest_column.rb | 17 +++++++++++++++++ ...01091124_remove_token_from_personal_access_tokens.rb | 11 +++++++++++ db/schema.rb | 2 -- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 db/post_migrate/20181101091005_steal_digest_column.rb create mode 100644 db/post_migrate/20181101091124_remove_token_from_personal_access_tokens.rb (limited to 'db') diff --git a/db/post_migrate/20181101091005_steal_digest_column.rb b/db/post_migrate/20181101091005_steal_digest_column.rb new file mode 100644 index 00000000000..58ea710c18a --- /dev/null +++ b/db/post_migrate/20181101091005_steal_digest_column.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class StealDigestColumn < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + Gitlab::BackgroundMigration.steal('DigestColumn') + end + + def down + # raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/post_migrate/20181101091124_remove_token_from_personal_access_tokens.rb b/db/post_migrate/20181101091124_remove_token_from_personal_access_tokens.rb new file mode 100644 index 00000000000..415373068d5 --- /dev/null +++ b/db/post_migrate/20181101091124_remove_token_from_personal_access_tokens.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class RemoveTokenFromPersonalAccessTokens < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + remove_column :personal_access_tokens, :token, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 25a645562ec..1651a24f412 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1515,7 +1515,6 @@ ActiveRecord::Schema.define(version: 20190204115450) do create_table "personal_access_tokens", force: :cascade do |t| t.integer "user_id", null: false - t.string "token" t.string "name", null: false t.boolean "revoked", default: false t.date "expires_at" @@ -1524,7 +1523,6 @@ ActiveRecord::Schema.define(version: 20190204115450) do t.string "scopes", default: "--- []\n", null: false t.boolean "impersonation", default: false, null: false t.string "token_digest" - t.index ["token"], name: "index_personal_access_tokens_on_token", unique: true, using: :btree t.index ["token_digest"], name: "index_personal_access_tokens_on_token_digest", unique: true, using: :btree t.index ["user_id"], name: "index_personal_access_tokens_on_user_id", using: :btree end -- cgit v1.2.3 From 28e1739a3fd8c93e4805fe0053faf820cec4e1bc Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 2 Apr 2018 14:26:59 +0000 Subject: Port EE System Header And Footer feature to CE remove EE specific code remove EE licence checks move migration from EE to CE folder structure move specs from EE to CE folder structure remove EE specific flag specs --- ...d_header_and_footer_banners_to_appearances_table.rb | 18 ++++++++++++++++++ db/schema.rb | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 db/migrate/20180314145917_add_header_and_footer_banners_to_appearances_table.rb (limited to 'db') diff --git a/db/migrate/20180314145917_add_header_and_footer_banners_to_appearances_table.rb b/db/migrate/20180314145917_add_header_and_footer_banners_to_appearances_table.rb new file mode 100644 index 00000000000..8aba3448035 --- /dev/null +++ b/db/migrate/20180314145917_add_header_and_footer_banners_to_appearances_table.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddHeaderAndFooterBannersToAppearancesTable < ActiveRecord::Migration[4.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :appearances, :header_message, :text + add_column :appearances, :header_message_html, :text + + add_column :appearances, :footer_message, :text + add_column :appearances, :footer_message_html, :text + + add_column :appearances, :message_background_color, :text + add_column :appearances, :message_font_color, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 1651a24f412..1bdc9682cc9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -37,6 +37,12 @@ ActiveRecord::Schema.define(version: 20190204115450) do t.integer "cached_markdown_version" t.text "new_project_guidelines" t.text "new_project_guidelines_html" + t.text "header_message" + t.text "header_message_html" + t.text "footer_message" + t.text "footer_message_html" + t.text "message_background_color" + t.text "message_font_color" t.string "favicon" end -- cgit v1.2.3 From c9125c4786970fc3c3745c7ea7bff45ef7a62e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Tue, 26 Feb 2019 14:03:42 +0000 Subject: Add Maskable concern for CI variables This adds a concern that abstracts the concept of masking a variable, including the RegEx for validation. --- .../20190218134158_add_masked_to_ci_variables.rb | 21 +++++++++++++++++++++ ...190218134209_add_masked_to_ci_group_variables.rb | 21 +++++++++++++++++++++ db/schema.rb | 4 +++- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190218134158_add_masked_to_ci_variables.rb create mode 100644 db/migrate/20190218134209_add_masked_to_ci_group_variables.rb (limited to 'db') diff --git a/db/migrate/20190218134158_add_masked_to_ci_variables.rb b/db/migrate/20190218134158_add_masked_to_ci_variables.rb new file mode 100644 index 00000000000..b4999d5b4a9 --- /dev/null +++ b/db/migrate/20190218134158_add_masked_to_ci_variables.rb @@ -0,0 +1,21 @@ +# 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 AddMaskedToCiVariables < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :ci_variables, :masked, :boolean, default: false, allow_null: false + end + + def down + remove_column :ci_variables, :masked + end +end diff --git a/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb b/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb new file mode 100644 index 00000000000..8633875b341 --- /dev/null +++ b/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb @@ -0,0 +1,21 @@ +# 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 AddMaskedToCiGroupVariables < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :ci_group_variables, :masked, :boolean, default: false, allow_null: false + end + + def down + remove_column :ci_group_variables, :masked + end +end diff --git a/db/schema.rb b/db/schema.rb index 1bdc9682cc9..f7bf6fb9cf7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190204115450) do +ActiveRecord::Schema.define(version: 20190218134209) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -405,6 +405,7 @@ ActiveRecord::Schema.define(version: 20190204115450) do t.boolean "protected", default: false, null: false t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false + t.boolean "masked", default: false, null: false t.index ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree end @@ -600,6 +601,7 @@ ActiveRecord::Schema.define(version: 20190204115450) do t.integer "project_id", null: false t.boolean "protected", default: false, null: false t.string "environment_scope", default: "*", null: false + t.boolean "masked", default: false, null: false t.index ["project_id", "key", "environment_scope"], name: "index_ci_variables_on_project_id_and_key_and_environment_scope", unique: true, using: :btree end -- cgit v1.2.3 From 7b445f9b15c31f7b2b53561901183ab23db2d636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Tue, 26 Feb 2019 17:32:23 +0000 Subject: Revert "Merge branch '13784-simple-masking-of-protected-variables-in-logs' into 'master'" This reverts merge request !25293 --- .../20190218134158_add_masked_to_ci_variables.rb | 21 --------------------- ...190218134209_add_masked_to_ci_group_variables.rb | 21 --------------------- db/schema.rb | 4 +--- 3 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 db/migrate/20190218134158_add_masked_to_ci_variables.rb delete mode 100644 db/migrate/20190218134209_add_masked_to_ci_group_variables.rb (limited to 'db') diff --git a/db/migrate/20190218134158_add_masked_to_ci_variables.rb b/db/migrate/20190218134158_add_masked_to_ci_variables.rb deleted file mode 100644 index b4999d5b4a9..00000000000 --- a/db/migrate/20190218134158_add_masked_to_ci_variables.rb +++ /dev/null @@ -1,21 +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 AddMaskedToCiVariables < ActiveRecord::Migration[5.0] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :ci_variables, :masked, :boolean, default: false, allow_null: false - end - - def down - remove_column :ci_variables, :masked - end -end diff --git a/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb b/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb deleted file mode 100644 index 8633875b341..00000000000 --- a/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb +++ /dev/null @@ -1,21 +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 AddMaskedToCiGroupVariables < ActiveRecord::Migration[5.0] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_column_with_default :ci_group_variables, :masked, :boolean, default: false, allow_null: false - end - - def down - remove_column :ci_group_variables, :masked - end -end diff --git a/db/schema.rb b/db/schema.rb index f7bf6fb9cf7..1bdc9682cc9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190218134209) do +ActiveRecord::Schema.define(version: 20190204115450) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -405,7 +405,6 @@ ActiveRecord::Schema.define(version: 20190218134209) do t.boolean "protected", default: false, null: false t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false - t.boolean "masked", default: false, null: false t.index ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree end @@ -601,7 +600,6 @@ ActiveRecord::Schema.define(version: 20190218134209) do t.integer "project_id", null: false t.boolean "protected", default: false, null: false t.string "environment_scope", default: "*", null: false - t.boolean "masked", default: false, null: false t.index ["project_id", "key", "environment_scope"], name: "index_ci_variables_on_project_id_and_key_and_environment_scope", unique: true, using: :btree end -- cgit v1.2.3 From 314062fec5a1d1f56a63202fa16fc7dacc876083 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 20 Feb 2019 15:37:49 +0900 Subject: Persist source sha and target sha for merge pipelines source_sha and target_sha are used for merge request pipelines --- db/migrate/20190220150130_add_extra_shas_to_ci_pipelines.rb | 12 ++++++++++++ db/schema.rb | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190220150130_add_extra_shas_to_ci_pipelines.rb (limited to 'db') diff --git a/db/migrate/20190220150130_add_extra_shas_to_ci_pipelines.rb b/db/migrate/20190220150130_add_extra_shas_to_ci_pipelines.rb new file mode 100644 index 00000000000..45c7c0949c6 --- /dev/null +++ b/db/migrate/20190220150130_add_extra_shas_to_ci_pipelines.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class AddExtraShasToCiPipelines < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_pipelines, :source_sha, :binary + add_column :ci_pipelines, :target_sha, :binary + end +end diff --git a/db/schema.rb b/db/schema.rb index 1bdc9682cc9..d835e48938d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190204115450) do +ActiveRecord::Schema.define(version: 20190220150130) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -497,6 +497,8 @@ ActiveRecord::Schema.define(version: 20190204115450) do t.integer "failure_reason" t.integer "iid" t.integer "merge_request_id" + t.binary "source_sha" + t.binary "target_sha" t.index ["auto_canceled_by_id"], name: "index_ci_pipelines_on_auto_canceled_by_id", using: :btree t.index ["merge_request_id"], name: "index_ci_pipelines_on_merge_request_id", where: "(merge_request_id IS NOT NULL)", using: :btree t.index ["pipeline_schedule_id"], name: "index_ci_pipelines_on_pipeline_schedule_id", using: :btree -- cgit v1.2.3 From 5ae9a44aa17c8929627cc450f936cd960c143e25 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Thu, 13 Dec 2018 20:26:56 +0100 Subject: Add project http fetch statistics API The API get projects/:id/traffic/fetches allows user with write access to the repository to get the number of clones for the last 30 days. --- .../20181205171941_create_project_daily_statistics.rb | 18 ++++++++++++++++++ db/schema.rb | 8 ++++++++ 2 files changed, 26 insertions(+) create mode 100644 db/migrate/20181205171941_create_project_daily_statistics.rb (limited to 'db') diff --git a/db/migrate/20181205171941_create_project_daily_statistics.rb b/db/migrate/20181205171941_create_project_daily_statistics.rb new file mode 100644 index 00000000000..c9e2a1e1aa7 --- /dev/null +++ b/db/migrate/20181205171941_create_project_daily_statistics.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class CreateProjectDailyStatistics < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :project_daily_statistics, id: :bigserial do |t| + t.integer :project_id, null: false + t.integer :fetch_count, null: false + t.date :date + + t.index [:project_id, :date], unique: true, order: { date: :desc } + t.foreign_key :projects, on_delete: :cascade + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1651a24f412..3a2bab1c57e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1578,6 +1578,13 @@ ActiveRecord::Schema.define(version: 20190204115450) do t.index ["project_id", "key"], name: "index_project_custom_attributes_on_project_id_and_key", unique: true, using: :btree end + create_table "project_daily_statistics", id: :bigserial, force: :cascade do |t| + t.integer "project_id", null: false + t.integer "fetch_count", null: false + t.date "date" + t.index ["project_id", "date"], name: "index_project_daily_statistics_on_project_id_and_date", unique: true, order: { date: :desc }, using: :btree + end + create_table "project_deploy_tokens", force: :cascade do |t| t.integer "project_id", null: false t.integer "deploy_token_id", null: false @@ -2461,6 +2468,7 @@ ActiveRecord::Schema.define(version: 20190204115450) do add_foreign_key "project_auto_devops", "projects", on_delete: :cascade add_foreign_key "project_ci_cd_settings", "projects", name: "fk_24c15d2f2e", on_delete: :cascade add_foreign_key "project_custom_attributes", "projects", on_delete: :cascade + add_foreign_key "project_daily_statistics", "projects", on_delete: :cascade add_foreign_key "project_deploy_tokens", "deploy_tokens", on_delete: :cascade add_foreign_key "project_deploy_tokens", "projects", on_delete: :cascade add_foreign_key "project_error_tracking_settings", "projects", on_delete: :cascade -- cgit v1.2.3 From 316889cb4789e8a4a43bf0c79a4269643a97c336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Wed, 27 Feb 2019 01:22:51 +0100 Subject: Revert "Merge branch 'revert-8baf9e5f' into 'master'" This reverts commit f5201a816f2eff9393e16f362403451e5d86ee6c, reversing changes made to 48e6db0dad6f256e8423e0bd6c9b254803f50ccf. --- .../20190218134158_add_masked_to_ci_variables.rb | 21 +++++++++++++++++++++ ...190218134209_add_masked_to_ci_group_variables.rb | 21 +++++++++++++++++++++ db/schema.rb | 2 ++ 3 files changed, 44 insertions(+) create mode 100644 db/migrate/20190218134158_add_masked_to_ci_variables.rb create mode 100644 db/migrate/20190218134209_add_masked_to_ci_group_variables.rb (limited to 'db') diff --git a/db/migrate/20190218134158_add_masked_to_ci_variables.rb b/db/migrate/20190218134158_add_masked_to_ci_variables.rb new file mode 100644 index 00000000000..b4999d5b4a9 --- /dev/null +++ b/db/migrate/20190218134158_add_masked_to_ci_variables.rb @@ -0,0 +1,21 @@ +# 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 AddMaskedToCiVariables < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :ci_variables, :masked, :boolean, default: false, allow_null: false + end + + def down + remove_column :ci_variables, :masked + end +end diff --git a/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb b/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb new file mode 100644 index 00000000000..8633875b341 --- /dev/null +++ b/db/migrate/20190218134209_add_masked_to_ci_group_variables.rb @@ -0,0 +1,21 @@ +# 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 AddMaskedToCiGroupVariables < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :ci_group_variables, :masked, :boolean, default: false, allow_null: false + end + + def down + remove_column :ci_group_variables, :masked + end +end diff --git a/db/schema.rb b/db/schema.rb index d835e48938d..86cb896f9a6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -405,6 +405,7 @@ ActiveRecord::Schema.define(version: 20190220150130) do t.boolean "protected", default: false, null: false t.datetime_with_timezone "created_at", null: false t.datetime_with_timezone "updated_at", null: false + t.boolean "masked", default: false, null: false t.index ["group_id", "key"], name: "index_ci_group_variables_on_group_id_and_key", unique: true, using: :btree end @@ -602,6 +603,7 @@ ActiveRecord::Schema.define(version: 20190220150130) do t.integer "project_id", null: false t.boolean "protected", default: false, null: false t.string "environment_scope", default: "*", null: false + t.boolean "masked", default: false, null: false t.index ["project_id", "key", "environment_scope"], name: "index_ci_variables_on_project_id_and_key_and_environment_scope", unique: true, using: :btree end -- cgit v1.2.3 From 4667b20c007c4bce248ac6cc458414fefa058bb8 Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Wed, 6 Feb 2019 20:35:22 +0100 Subject: add trigram database index on tags --- db/migrate/20190206193120_add_index_to_tags.rb | 18 ++++++++++++++++++ db/schema.rb | 1 + 2 files changed, 19 insertions(+) create mode 100644 db/migrate/20190206193120_add_index_to_tags.rb (limited to 'db') diff --git a/db/migrate/20190206193120_add_index_to_tags.rb b/db/migrate/20190206193120_add_index_to_tags.rb new file mode 100644 index 00000000000..5257ebba003 --- /dev/null +++ b/db/migrate/20190206193120_add_index_to_tags.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexToTags < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_tags_on_name_trigram' + + disable_ddl_transaction! + + def up + add_concurrent_index :tags, :name, name: INDEX_NAME, using: :gin, opclasses: { name: :gin_trgm_ops } + end + + def down + remove_concurrent_index_by_name(:tags, INDEX_NAME) + end +end diff --git a/db/schema.rb b/db/schema.rb index a7a83475679..d4166e32112 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2053,6 +2053,7 @@ ActiveRecord::Schema.define(version: 20190220150130) do t.string "name" t.integer "taggings_count", default: 0 t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree + t.index ["name"], name: "index_tags_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} end create_table "term_agreements", force: :cascade do |t| -- cgit v1.2.3 From 77985826d94454514c40b8da926e13b3b3791841 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 20 Feb 2019 17:18:15 +0200 Subject: Show header and footer system messages in email * Add email_header_and_footer_enabled flag to appearances table * Set email_header_and_footer_enabled default value to false * Add checkbox to appearance to toggle show header and footer in emails * Add email_header_and_footer_enabled to allowed params in controller * Add header and footer messages to the html and text email layouts * Remove the color styling for emails header and footer * Add empty_mailer layout for emails without layout, to have the header and footer applied --- ...ader_and_footer_enabled_flag_to_appearances_table.rb | 17 +++++++++++++++++ db/schema.rb | 1 + 2 files changed, 18 insertions(+) create mode 100644 db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb (limited to 'db') diff --git a/db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb b/db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb new file mode 100644 index 00000000000..85b9e0580f4 --- /dev/null +++ b/db/migrate/20190220142344_add_email_header_and_footer_enabled_flag_to_appearances_table.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AddEmailHeaderAndFooterEnabledFlagToAppearancesTable < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + DOWNTIME = false + + def up + add_column_with_default(:appearances, :email_header_and_footer_enabled, :boolean, default: false) + end + + def down + remove_column(:appearances, :email_header_and_footer_enabled) + end +end diff --git a/db/schema.rb b/db/schema.rb index a7a83475679..efb0aa7bf7c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -44,6 +44,7 @@ ActiveRecord::Schema.define(version: 20190220150130) do t.text "message_background_color" t.text "message_font_color" t.string "favicon" + t.boolean "email_header_and_footer_enabled", default: false, null: false end create_table "application_setting_terms", force: :cascade do |t| -- cgit v1.2.3 From 6bbc380127d64dcb1dd755dd8082e619fe71bf4e Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 19 Feb 2019 17:49:12 +0900 Subject: Add project level config for merge pipelines Add schema Add CE counter part Add default value for Add changelog Fix schema Add test Fix schema Fix schema version Remove default value for --- ...215154930_add_merge_pipelines_enabled_to_ci_cd_settings.rb | 11 +++++++++++ db/schema.rb | 1 + 2 files changed, 12 insertions(+) create mode 100644 db/migrate/20190215154930_add_merge_pipelines_enabled_to_ci_cd_settings.rb (limited to 'db') diff --git a/db/migrate/20190215154930_add_merge_pipelines_enabled_to_ci_cd_settings.rb b/db/migrate/20190215154930_add_merge_pipelines_enabled_to_ci_cd_settings.rb new file mode 100644 index 00000000000..2a2a216da7d --- /dev/null +++ b/db/migrate/20190215154930_add_merge_pipelines_enabled_to_ci_cd_settings.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class AddMergePipelinesEnabledToCiCdSettings < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :project_ci_cd_settings, :merge_pipelines_enabled, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index d4166e32112..7dfa9222278 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1575,6 +1575,7 @@ ActiveRecord::Schema.define(version: 20190220150130) do create_table "project_ci_cd_settings", force: :cascade do |t| t.integer "project_id", null: false t.boolean "group_runners_enabled", default: true, null: false + t.boolean "merge_pipelines_enabled" t.index ["project_id"], name: "index_project_ci_cd_settings_on_project_id", unique: true, using: :btree end -- cgit v1.2.3 From 347c884cb25e3ed428cf3db62e73658dc20a22b0 Mon Sep 17 00:00:00 2001 From: Heinrich Lee Yu Date: Thu, 28 Feb 2019 19:15:30 +0800 Subject: Clean up `noteable_id` for notes on commits This was incorrectly set by a bug in: https://gitlab.com/gitlab-org/gitlab-ce/issues/54924 --- ...16_clean_up_noteable_id_for_notes_on_commits.rb | 33 ++++++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.rb (limited to 'db') diff --git a/db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.rb b/db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.rb new file mode 100644 index 00000000000..fe129e8f4dc --- /dev/null +++ b/db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.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 CleanUpNoteableIdForNotesOnCommits < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + TEMP_INDEX_NAME = 'index_notes_on_commit_with_null_noteable_id' + + disable_ddl_transaction! + + def up + remove_concurrent_index_by_name(:notes, TEMP_INDEX_NAME) + + add_concurrent_index(:notes, :id, where: "noteable_type = 'Commit' AND noteable_id IS NOT NULL", name: TEMP_INDEX_NAME) + + # rubocop:disable Migration/UpdateLargeTable + update_column_in_batches(:notes, :noteable_id, nil) do |table, query| + query.where( + table[:noteable_type].eq('Commit').and(table[:noteable_id].not_eq(nil)) + ) + end + + remove_concurrent_index_by_name(:notes, TEMP_INDEX_NAME) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index e569200d12e..24a98c374ca 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190220150130) do +ActiveRecord::Schema.define(version: 20190228092516) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 61d77a042da2ada48cdcd83f97923780aac407f4 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Fri, 1 Mar 2019 08:20:52 +0100 Subject: Migrate sidekiq queue to the new :hashed_storage namespace `project_migrate_hashed_storage` is now `hashed_storage:hashed_storage_project_migrate` --- ...90301081611_migrate_project_migrate_sidekiq_queue.rb | 17 +++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 db/post_migrate/20190301081611_migrate_project_migrate_sidekiq_queue.rb (limited to 'db') diff --git a/db/post_migrate/20190301081611_migrate_project_migrate_sidekiq_queue.rb b/db/post_migrate/20190301081611_migrate_project_migrate_sidekiq_queue.rb new file mode 100644 index 00000000000..6af7902e0c4 --- /dev/null +++ b/db/post_migrate/20190301081611_migrate_project_migrate_sidekiq_queue.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class MigrateProjectMigrateSidekiqQueue < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + DOWNTIME = false + + def up + sidekiq_queue_migrate 'project_migrate_hashed_storage', to: 'hashed_storage:hashed_storage_project_migrate' + end + + def down + sidekiq_queue_migrate 'hashed_storage:hashed_storage_project_migrate', to: 'project_migrate_hashed_storage' + end +end diff --git a/db/schema.rb b/db/schema.rb index 24a98c374ca..2ddc8358433 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190228092516) do +ActiveRecord::Schema.define(version: 20190301081611) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From c5f1f7f3dbd5e7094ae3f30823d6c87b7a72121d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 6 Mar 2019 12:18:53 +0000 Subject: Use encrypted runner tokens This makes code to support encrypted runner tokens. This code also finished previously started encryption process. --- .../20190225160300_steal_encrypt_runners_tokens.rb | 19 +++++++++++++++++ .../20190225160301_add_runner_tokens_indexes.rb | 24 ++++++++++++++++++++++ db/schema.rb | 3 +++ 3 files changed, 46 insertions(+) create mode 100644 db/migrate/20190225160300_steal_encrypt_runners_tokens.rb create mode 100644 db/migrate/20190225160301_add_runner_tokens_indexes.rb (limited to 'db') diff --git a/db/migrate/20190225160300_steal_encrypt_runners_tokens.rb b/db/migrate/20190225160300_steal_encrypt_runners_tokens.rb new file mode 100644 index 00000000000..18c0d2a2e1b --- /dev/null +++ b/db/migrate/20190225160300_steal_encrypt_runners_tokens.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class StealEncryptRunnersTokens < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + # This cleans after `EncryptRunnersTokens` + + DOWNTIME = false + + disable_ddl_transaction! + + def up + Gitlab::BackgroundMigration.steal('EncryptRunnersTokens') + end + + def down + # no-op + end +end diff --git a/db/migrate/20190225160301_add_runner_tokens_indexes.rb b/db/migrate/20190225160301_add_runner_tokens_indexes.rb new file mode 100644 index 00000000000..3230c2809de --- /dev/null +++ b/db/migrate/20190225160301_add_runner_tokens_indexes.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class AddRunnerTokensIndexes < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + # It seems that `ci_runners.token_encrypted` and `projects.runners_token_encrypted` + # are non-unique + + def up + add_concurrent_index :ci_runners, :token_encrypted + add_concurrent_index :projects, :runners_token_encrypted + add_concurrent_index :namespaces, :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, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ddc8358433..c782524c391 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -556,6 +556,7 @@ ActiveRecord::Schema.define(version: 20190301081611) do t.index ["locked"], name: "index_ci_runners_on_locked", using: :btree t.index ["runner_type"], name: "index_ci_runners_on_runner_type", using: :btree t.index ["token"], name: "index_ci_runners_on_token", using: :btree + t.index ["token_encrypted"], name: "index_ci_runners_on_token_encrypted", using: :btree end create_table "ci_stages", force: :cascade do |t| @@ -1383,6 +1384,7 @@ ActiveRecord::Schema.define(version: 20190301081611) do t.index ["path"], name: "index_namespaces_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} t.index ["require_two_factor_authentication"], name: "index_namespaces_on_require_two_factor_authentication", using: :btree t.index ["runners_token"], name: "index_namespaces_on_runners_token", unique: true, using: :btree + t.index ["runners_token_encrypted"], name: "index_namespaces_on_runners_token_encrypted", unique: true, using: :btree t.index ["type"], name: "index_namespaces_on_type", using: :btree end @@ -1752,6 +1754,7 @@ ActiveRecord::Schema.define(version: 20190301081611) do t.index ["repository_storage", "created_at"], name: "idx_project_repository_check_partial", where: "(last_repository_check_at IS NULL)", using: :btree t.index ["repository_storage"], name: "index_projects_on_repository_storage", using: :btree t.index ["runners_token"], name: "index_projects_on_runners_token", using: :btree + t.index ["runners_token_encrypted"], name: "index_projects_on_runners_token_encrypted", using: :btree t.index ["star_count"], name: "index_projects_on_star_count", using: :btree t.index ["visibility_level"], name: "index_projects_on_visibility_level", using: :btree end -- cgit v1.2.3 From ce23d6e64d59a8fadcc86bb25a157607322b09e3 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 6 Mar 2019 13:05:55 -0500 Subject: Revert "Merge branch '54924-clean-up-data' into 'master'" This reverts commit c9ecc71ab91b0b55f9aba632f9e7b305191a458c, reversing changes made to c3c8dbf8fa4090bb090071d320a31857eb709d3d. --- ...16_clean_up_noteable_id_for_notes_on_commits.rb | 33 ---------------------- 1 file changed, 33 deletions(-) delete mode 100644 db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.rb (limited to 'db') diff --git a/db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.rb b/db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.rb deleted file mode 100644 index fe129e8f4dc..00000000000 --- a/db/migrate/20190228092516_clean_up_noteable_id_for_notes_on_commits.rb +++ /dev/null @@ -1,33 +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 CleanUpNoteableIdForNotesOnCommits < ActiveRecord::Migration[5.0] - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - TEMP_INDEX_NAME = 'index_notes_on_commit_with_null_noteable_id' - - disable_ddl_transaction! - - def up - remove_concurrent_index_by_name(:notes, TEMP_INDEX_NAME) - - add_concurrent_index(:notes, :id, where: "noteable_type = 'Commit' AND noteable_id IS NOT NULL", name: TEMP_INDEX_NAME) - - # rubocop:disable Migration/UpdateLargeTable - update_column_in_batches(:notes, :noteable_id, nil) do |table, query| - query.where( - table[:noteable_type].eq('Commit').and(table[:noteable_id].not_eq(nil)) - ) - end - - remove_concurrent_index_by_name(:notes, TEMP_INDEX_NAME) - end - - def down - end -end -- cgit v1.2.3 From 460797dec3dc143943390e86a09d6e6b45a465d8 Mon Sep 17 00:00:00 2001 From: walkafwalka <2865898-walkafwalka@users.noreply.gitlab.com> Date: Thu, 7 Mar 2019 13:51:43 -0800 Subject: Add support for ingress hostnames --- ...90301182457_add_external_hostname_to_ingress_and_knative.rb | 10 ++++++++++ db/schema.rb | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190301182457_add_external_hostname_to_ingress_and_knative.rb (limited to 'db') diff --git a/db/migrate/20190301182457_add_external_hostname_to_ingress_and_knative.rb b/db/migrate/20190301182457_add_external_hostname_to_ingress_and_knative.rb new file mode 100644 index 00000000000..2c3a54b12a9 --- /dev/null +++ b/db/migrate/20190301182457_add_external_hostname_to_ingress_and_knative.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AddExternalHostnameToIngressAndKnative < ActiveRecord::Migration[5.0] + DOWNTIME = false + + def change + add_column :clusters_applications_ingress, :external_hostname, :string + add_column :clusters_applications_knative, :external_hostname, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index c782524c391..59a76e21a5f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190301081611) do +ActiveRecord::Schema.define(version: 20190301182457) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -708,6 +708,7 @@ ActiveRecord::Schema.define(version: 20190301081611) do t.string "cluster_ip" t.text "status_reason" t.string "external_ip" + t.string "external_hostname" t.index ["cluster_id"], name: "index_clusters_applications_ingress_on_cluster_id", unique: true, using: :btree end @@ -733,6 +734,7 @@ ActiveRecord::Schema.define(version: 20190301081611) do t.string "hostname" t.text "status_reason" t.string "external_ip" + t.string "external_hostname" t.index ["cluster_id"], name: "index_clusters_applications_knative_on_cluster_id", unique: true, using: :btree end -- cgit v1.2.3 From 64bf46af38190bf24569add6095a9a8bbced0a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 11 Mar 2019 16:16:58 +0100 Subject: Add labels to seeded issues and merge requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/fixtures/development/02_settings.rb | 8 ++ db/fixtures/development/03_project.rb | 137 ++++++++++++++++++++++ db/fixtures/development/03_settings.rb | 8 -- db/fixtures/development/04_labels.rb | 49 ++++++++ db/fixtures/development/04_project.rb | 137 ---------------------- db/fixtures/development/09_issues.rb | 6 +- db/fixtures/development/10_merge_requests.rb | 6 +- db/fixtures/development/22_labeled_issues_seed.rb | 103 ---------------- 8 files changed, 204 insertions(+), 250 deletions(-) create mode 100644 db/fixtures/development/02_settings.rb create mode 100644 db/fixtures/development/03_project.rb delete mode 100644 db/fixtures/development/03_settings.rb create mode 100644 db/fixtures/development/04_labels.rb delete mode 100644 db/fixtures/development/04_project.rb delete mode 100644 db/fixtures/development/22_labeled_issues_seed.rb (limited to 'db') diff --git a/db/fixtures/development/02_settings.rb b/db/fixtures/development/02_settings.rb new file mode 100644 index 00000000000..3a4a5d436bf --- /dev/null +++ b/db/fixtures/development/02_settings.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Enable hashed storage, in development mode, for all projects by default. +Gitlab::Seeder.quiet do + ApplicationSetting.create_from_defaults unless ApplicationSetting.current_without_cache + ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true) + print '.' +end diff --git a/db/fixtures/development/03_project.rb b/db/fixtures/development/03_project.rb new file mode 100644 index 00000000000..46018cf68aa --- /dev/null +++ b/db/fixtures/development/03_project.rb @@ -0,0 +1,137 @@ +require './spec/support/sidekiq' + +# rubocop:disable Rails/Output + +Sidekiq::Testing.inline! do + Gitlab::Seeder.quiet do + Gitlab::Seeder.without_gitaly_timeout do + project_urls = %w[ + https://gitlab.com/gitlab-org/gitlab-test.git + https://gitlab.com/gitlab-org/gitlab-shell.git + https://gitlab.com/gnuwget/wget2.git + https://gitlab.com/Commit451/LabCoat.git + https://github.com/jashkenas/underscore.git + https://github.com/flightjs/flight.git + https://github.com/twitter/typeahead.js.git + https://github.com/h5bp/html5-boilerplate.git + https://github.com/google/material-design-lite.git + https://github.com/jlevy/the-art-of-command-line.git + https://github.com/FreeCodeCamp/freecodecamp.git + https://github.com/google/deepdream.git + https://github.com/jtleek/datasharing.git + https://github.com/WebAssembly/design.git + https://github.com/airbnb/javascript.git + https://github.com/tessalt/echo-chamber-js.git + https://github.com/atom/atom.git + https://github.com/mattermost/mattermost-server.git + https://github.com/purifycss/purifycss.git + https://github.com/facebook/nuclide.git + https://github.com/wbkd/awesome-d3.git + https://github.com/kilimchoi/engineering-blogs.git + https://github.com/gilbarbara/logos.git + https://github.com/reduxjs/redux.git + https://github.com/awslabs/s2n.git + https://github.com/arkency/reactjs_koans.git + https://github.com/twbs/bootstrap.git + https://github.com/chjj/ttystudio.git + https://github.com/MostlyAdequate/mostly-adequate-guide.git + https://github.com/octocat/Spoon-Knife.git + https://github.com/opencontainers/runc.git + https://github.com/googlesamples/android-topeka.git + ] + + large_project_urls = %w[ + https://github.com/torvalds/linux.git + https://gitlab.gnome.org/GNOME/gimp.git + https://gitlab.gnome.org/GNOME/gnome-mud.git + https://gitlab.com/fdroid/fdroidclient.git + https://gitlab.com/inkscape/inkscape.git + https://github.com/gnachman/iTerm2.git + ] + + def create_project(url, force_latest_storage: false) + group_path, project_path = url.split('/')[-2..-1] + + group = Group.find_by(path: group_path) + + unless group + group = Group.new( + name: group_path.titleize, + path: group_path + ) + group.description = FFaker::Lorem.sentence + group.save! + + group.add_owner(User.first) + end + + project_path.gsub!(".git", "") + + params = { + import_url: url, + namespace_id: group.id, + name: project_path.titleize, + description: FFaker::Lorem.sentence, + visibility_level: Gitlab::VisibilityLevel.values.sample, + skip_disk_validation: true + } + + if force_latest_storage + params[:storage_version] = Project::LATEST_STORAGE_VERSION + end + + project = nil + + Sidekiq::Worker.skipping_transaction_check do + project = Projects::CreateService.new(User.first, params).execute + + # Seed-Fu runs this entire fixture in a transaction, so the `after_commit` + # hook won't run until after the fixture is loaded. That is too late + # since the Sidekiq::Testing block has already exited. Force clearing + # the `after_commit` queue to ensure the job is run now. + project.send(:_run_after_commit_queue) + project.import_state.send(:_run_after_commit_queue) + end + + if project.valid? && project.valid_repo? + print '.' + else + puts project.errors.full_messages + print 'F' + end + end + + # You can specify how many projects you need during seed execution + size = ENV['SIZE'].present? ? ENV['SIZE'].to_i : 8 + + project_urls.first(size).each_with_index do |url, i| + create_project(url, force_latest_storage: i.even?) + end + + if ENV['LARGE_PROJECTS'].present? + large_project_urls.each(&method(:create_project)) + + if ENV['FORK'].present? + puts "\nGenerating forks" + + project_name = ENV['FORK'] == 'true' ? 'torvalds/linux' : ENV['FORK'] + + project = Project.find_by_full_path(project_name) + + User.offset(1).first(5).each do |user| + new_project = Projects::ForkService.new(project, user).execute + + if new_project.valid? && (new_project.valid_repo? || new_project.import_state.scheduled?) + print '.' + else + new_project.errors.full_messages.each do |error| + puts "#{new_project.full_path}: #{error}" + end + print 'F' + end + end + end + end + end + end +end diff --git a/db/fixtures/development/03_settings.rb b/db/fixtures/development/03_settings.rb deleted file mode 100644 index 3a4a5d436bf..00000000000 --- a/db/fixtures/development/03_settings.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -# Enable hashed storage, in development mode, for all projects by default. -Gitlab::Seeder.quiet do - ApplicationSetting.create_from_defaults unless ApplicationSetting.current_without_cache - ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true) - print '.' -end diff --git a/db/fixtures/development/04_labels.rb b/db/fixtures/development/04_labels.rb new file mode 100644 index 00000000000..b9ae4098d76 --- /dev/null +++ b/db/fixtures/development/04_labels.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require 'digest/md5' + +class Gitlab::Seeder::GroupLabels + def initialize(group, label_per_group: 10) + @group = group + @label_per_group = label_per_group + end + + def seed! + @label_per_group.times do + label_title = FFaker::Product.brand + Labels::CreateService + .new(title: label_title, color: "##{Digest::MD5.hexdigest(label_title)[0..5]}") + .execute(group: @group) + print '.' + end + end +end + +class Gitlab::Seeder::ProjectLabels + def initialize(project, label_per_project: 5) + @project = project + @label_per_project = label_per_project + end + + def seed! + @label_per_project.times do + label_title = FFaker::Vehicle.model + Labels::CreateService + .new(title: label_title, color: "##{Digest::MD5.hexdigest(label_title)[0..5]}") + .execute(project: @project) + print '.' + end + end +end + +Gitlab::Seeder.quiet do + puts "\nGenerating group labels" + Group.all.find_each do |group| + Gitlab::Seeder::GroupLabels.new(group).seed! + end + + puts "\nGenerating project labels" + Project.all.find_each do |project| + Gitlab::Seeder::ProjectLabels.new(project).seed! + end +end diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb deleted file mode 100644 index 9a5f7cf8175..00000000000 --- a/db/fixtures/development/04_project.rb +++ /dev/null @@ -1,137 +0,0 @@ -require './spec/support/sidekiq' - -# rubocop:disable Rails/Output - -Sidekiq::Testing.inline! do - Gitlab::Seeder.quiet do - Gitlab::Seeder.without_gitaly_timeout do - project_urls = %w[ - https://gitlab.com/gitlab-org/gitlab-test.git - https://gitlab.com/gitlab-org/gitlab-shell.git - https://gitlab.com/gnuwget/wget2.git - https://gitlab.com/Commit451/LabCoat.git - https://github.com/jashkenas/underscore.git - https://github.com/flightjs/flight.git - https://github.com/twitter/typeahead.js.git - https://github.com/h5bp/html5-boilerplate.git - https://github.com/google/material-design-lite.git - https://github.com/jlevy/the-art-of-command-line.git - https://github.com/FreeCodeCamp/freecodecamp.git - https://github.com/google/deepdream.git - https://github.com/jtleek/datasharing.git - https://github.com/WebAssembly/design.git - https://github.com/airbnb/javascript.git - https://github.com/tessalt/echo-chamber-js.git - https://github.com/atom/atom.git - https://github.com/mattermost/mattermost-server.git - https://github.com/purifycss/purifycss.git - https://github.com/facebook/nuclide.git - https://github.com/wbkd/awesome-d3.git - https://github.com/kilimchoi/engineering-blogs.git - https://github.com/gilbarbara/logos.git - https://github.com/reduxjs/redux.git - https://github.com/awslabs/s2n.git - https://github.com/arkency/reactjs_koans.git - https://github.com/twbs/bootstrap.git - https://github.com/chjj/ttystudio.git - https://github.com/MostlyAdequate/mostly-adequate-guide.git - https://github.com/octocat/Spoon-Knife.git - https://github.com/opencontainers/runc.git - https://github.com/googlesamples/android-topeka.git - ] - - large_project_urls = %w[ - https://github.com/torvalds/linux.git - https://gitlab.gnome.org/GNOME/gimp.git - https://gitlab.gnome.org/GNOME/gnome-mud.git - https://gitlab.com/fdroid/fdroidclient.git - https://gitlab.com/inkscape/inkscape.git - https://github.com/gnachman/iTerm2.git - ] - - def create_project(url, force_latest_storage: false) - group_path, project_path = url.split('/')[-2..-1] - - group = Group.find_by(path: group_path) - - unless group - group = Group.new( - name: group_path.titleize, - path: group_path - ) - group.description = FFaker::Lorem.sentence - group.save - - group.add_owner(User.first) - end - - project_path.gsub!(".git", "") - - params = { - import_url: url, - namespace_id: group.id, - name: project_path.titleize, - description: FFaker::Lorem.sentence, - visibility_level: Gitlab::VisibilityLevel.values.sample, - skip_disk_validation: true - } - - if force_latest_storage - params[:storage_version] = Project::LATEST_STORAGE_VERSION - end - - project = nil - - Sidekiq::Worker.skipping_transaction_check do - project = Projects::CreateService.new(User.first, params).execute - - # Seed-Fu runs this entire fixture in a transaction, so the `after_commit` - # hook won't run until after the fixture is loaded. That is too late - # since the Sidekiq::Testing block has already exited. Force clearing - # the `after_commit` queue to ensure the job is run now. - project.send(:_run_after_commit_queue) - project.import_state.send(:_run_after_commit_queue) - end - - if project.valid? && project.valid_repo? - print '.' - else - puts project.errors.full_messages - print 'F' - end - end - - # You can specify how many projects you need during seed execution - size = ENV['SIZE'].present? ? ENV['SIZE'].to_i : 8 - - project_urls.first(size).each_with_index do |url, i| - create_project(url, force_latest_storage: i.even?) - end - - if ENV['LARGE_PROJECTS'].present? - large_project_urls.each(&method(:create_project)) - - if ENV['FORK'].present? - puts "\nGenerating forks" - - project_name = ENV['FORK'] == 'true' ? 'torvalds/linux' : ENV['FORK'] - - project = Project.find_by_full_path(project_name) - - User.offset(1).first(5).each do |user| - new_project = Projects::ForkService.new(project, user).execute - - if new_project.valid? && (new_project.valid_repo? || new_project.import_state.scheduled?) - print '.' - else - new_project.errors.full_messages.each do |error| - puts "#{new_project.full_path}: #{error}" - end - print 'F' - end - end - end - end - end - end -end diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb index 16243b72f9a..926401d8b9e 100644 --- a/db/fixtures/development/09_issues.rb +++ b/db/fixtures/development/09_issues.rb @@ -3,13 +3,17 @@ require './spec/support/sidekiq' Gitlab::Seeder.quiet do Project.all.each do |project| 10.times do + label_ids = project.labels.pluck(:id).sample(3) + label_ids += project.group.labels.sample(3) if project.group + issue_params = { title: FFaker::Lorem.sentence(6), description: FFaker::Lorem.sentence, state: ['opened', 'closed'].sample, milestone: project.milestones.sample, assignees: [project.team.users.sample], - created_at: rand(12).months.ago + created_at: rand(12).months.ago, + label_ids: label_ids } Issues::CreateService.new(project, project.team.users.sample, issue_params).execute diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb index 2051bcff8f0..1952f84ed62 100644 --- a/db/fixtures/development/10_merge_requests.rb +++ b/db/fixtures/development/10_merge_requests.rb @@ -12,13 +12,17 @@ Gitlab::Seeder.quiet do source_branch = branches.pop target_branch = branches.pop + label_ids = project.labels.pluck(:id).sample(3) + label_ids += project.group.labels.sample(3) if project.group + params = { source_branch: source_branch, target_branch: target_branch, title: FFaker::Lorem.sentence(6), description: FFaker::Lorem.sentences(3).join(" "), milestone: project.milestones.sample, - assignee: project.team.users.sample + assignee: project.team.users.sample, + label_ids: label_ids } # Only create MRs with users that are allowed to create MRs diff --git a/db/fixtures/development/22_labeled_issues_seed.rb b/db/fixtures/development/22_labeled_issues_seed.rb deleted file mode 100644 index 3730e9c7958..00000000000 --- a/db/fixtures/development/22_labeled_issues_seed.rb +++ /dev/null @@ -1,103 +0,0 @@ -# Creates a project with labeled issues for an user. -# Run this single seed file using: rake db:seed_fu FILTER=labeled USER_ID=74. -# If an USER_ID is not provided it will use the last created user. -require './spec/support/sidekiq' - -class Gitlab::Seeder::LabeledIssues - include ::Gitlab::Utils - - def initialize(user) - @user = user - end - - def seed! - Sidekiq::Testing.inline! do - group = create_group - - create_projects(group) - create_labels(group) - create_issues(group) - end - - print '.' - end - - private - - def create_group - group_name = "group_of_#{@user.username}_#{SecureRandom.hex(4)}" - - group_params = { - name: group_name, - path: group_name, - description: FFaker::Lorem.sentence - } - - Groups::CreateService.new(@user, group_params).execute - end - - def create_projects(group) - 5.times do - project_name = "project_#{SecureRandom.hex(6)}" - - params = { - namespace_id: group.id, - name: project_name, - description: FFaker::Lorem.sentence, - visibility_level: Gitlab::VisibilityLevel.values.sample - } - - Projects::CreateService.new(@user, params).execute - end - end - - def create_labels(group) - group.projects.each do |project| - 5.times do - label_title = FFaker::Vehicle.model - Labels::CreateService.new(title: label_title, color: "#69D100").execute(project: project) - end - end - - 10.times do - label_title = FFaker::Product.brand - Labels::CreateService.new(title: label_title).execute(group: group) - end - end - - def create_issues(group) - # Get only group labels - group_labels = - LabelsFinder.new(@user, group_id: group.id).execute.where.not(group_id: nil) - - group.projects.each do |project| - label_ids = project.labels.pluck(:id).sample(5) - label_ids.push(*group.labels.sample(4)) - - 20.times do - issue_params = { - title: FFaker::Lorem.sentence(6), - description: FFaker::Lorem.sentence, - state: 'opened', - label_ids: label_ids - - } - - Issues::CreateService.new(project, @user, issue_params).execute if project.project_feature.present? - end - end - end -end - -Gitlab::Seeder.quiet do - user_id = ENV['USER_ID'] - - user = - if user_id.present? - User.find(user_id) - else - User.last - end - - Gitlab::Seeder::LabeledIssues.new(user).seed! -end -- cgit v1.2.3 From 7e9348f3594ee158dfd4aaa9e03e5bb5dd36aead Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 12 Mar 2019 10:15:33 +0000 Subject: Enable/disable Auto DevOps at Group level - Includes instance methods on Group model to detect when a group has AutoDevOps explicitly/implicitly enabled/disabled. - Includes migration to add a new column to namespaces table - Add UI necessary modifications - Add service and controller to update auto devops related instances - Updates project and groups auto devops badges Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52447 --- .../20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb | 9 +++++++++ db/schema.rb | 1 + 2 files changed, 10 insertions(+) create mode 100644 db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb (limited to 'db') diff --git a/db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb b/db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb new file mode 100644 index 00000000000..93e7a84fb02 --- /dev/null +++ b/db/migrate/20190225152525_add_auto_dev_ops_enabled_to_namespaces.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddAutoDevOpsEnabledToNamespaces < ActiveRecord::Migration[5.0] + DOWNTIME = false + + def change + add_column :namespaces, :auto_devops_enabled, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 59a76e21a5f..dda0445e3f2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1377,6 +1377,7 @@ ActiveRecord::Schema.define(version: 20190301182457) do t.integer "cached_markdown_version" t.string "runners_token" t.string "runners_token_encrypted" + t.boolean "auto_devops_enabled" t.index ["created_at"], name: "index_namespaces_on_created_at", using: :btree t.index ["name", "parent_id"], name: "index_namespaces_on_name_and_parent_id", unique: true, using: :btree t.index ["name"], name: "index_namespaces_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} -- cgit v1.2.3 From 9f05e97aad33a0cd70862f67101bdcb3fddc639a Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Wed, 13 Mar 2019 13:42:43 +0000 Subject: Run rubocop -a --- ...20170530130129_project_foreign_keys_with_cascading_deletes.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'db') diff --git a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb index d40c61f24b1..b4658bc4017 100644 --- a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb +++ b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb @@ -126,11 +126,10 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2] queues.each do |queue| # Stealing is racy so it's possible a pop might be called on an # already-empty queue. - begin - remove_orphans(*queue.pop(true)) - stolen = true - rescue ThreadError - end + + remove_orphans(*queue.pop(true)) + stolen = true + rescue ThreadError end break unless stolen -- cgit v1.2.3 From 929ee4d18da886826e9fcc15c35b4d4024bc8237 Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Fri, 22 Mar 2019 13:51:47 -0300 Subject: Add multiple assignees migration and table population This will be further required for supporting multi-assignees MRs --- ...5191339_create_merge_request_assignees_table.rb | 22 +++++++++++++++++++++ ...edule_populate_merge_request_assignees_table.rb | 23 ++++++++++++++++++++++ db/schema.rb | 12 ++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20190315191339_create_merge_request_assignees_table.rb create mode 100644 db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb (limited to 'db') diff --git a/db/migrate/20190315191339_create_merge_request_assignees_table.rb b/db/migrate/20190315191339_create_merge_request_assignees_table.rb new file mode 100644 index 00000000000..6fc4463f281 --- /dev/null +++ b/db/migrate/20190315191339_create_merge_request_assignees_table.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class CreateMergeRequestAssigneesTable < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + INDEX_NAME = 'index_merge_request_assignees_on_merge_request_id_and_user_id' + + def up + create_table :merge_request_assignees do |t| + t.references :user, foreign_key: { on_delete: :cascade }, index: true, null: false + t.references :merge_request, foreign_key: { on_delete: :cascade }, null: false + end + + add_index :merge_request_assignees, [:merge_request_id, :user_id], unique: true, name: INDEX_NAME + end + + def down + drop_table :merge_request_assignees + end +end diff --git a/db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb b/db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb new file mode 100644 index 00000000000..1ecb38e1a86 --- /dev/null +++ b/db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb @@ -0,0 +1,23 @@ +# 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 SchedulePopulateMergeRequestAssigneesTable < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 10_000 + MIGRATION = 'PopulateMergeRequestAssigneesTable' + DELAY_INTERVAL = 8.minutes.to_i + + disable_ddl_transaction! + + def up + say 'Scheduling `PopulateMergeRequestAssigneesTable` jobs' + # We currently have ~4_500_000 merge request records on GitLab.com. + # This means it'll schedule ~450 jobs (10k MRs each) with a 8 minutes gap, + # so this should take ~60 hours for all background migrations to complete. + queue_background_migration_jobs_by_range_at_intervals(MergeRequest, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) + end +end diff --git a/db/schema.rb b/db/schema.rb index dda0445e3f2..0c997f3b8a2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190301182457) do +ActiveRecord::Schema.define(version: 20190322132835) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1201,6 +1201,14 @@ ActiveRecord::Schema.define(version: 20190301182457) do t.index ["user_id"], name: "index_members_on_user_id", using: :btree end + create_table "merge_request_assignees", force: :cascade do |t| + t.integer "user_id", null: false + t.integer "merge_request_id", null: false + t.index ["merge_request_id", "user_id"], name: "index_merge_request_assignees_on_merge_request_id_and_user_id", unique: true, using: :btree + t.index ["merge_request_id"], name: "index_merge_request_assignees_on_merge_request_id", using: :btree + t.index ["user_id"], name: "index_merge_request_assignees_on_user_id", using: :btree + end + create_table "merge_request_diff_commits", id: false, force: :cascade do |t| t.datetime_with_timezone "authored_date" t.datetime_with_timezone "committed_date" @@ -2454,6 +2462,8 @@ ActiveRecord::Schema.define(version: 20190301182457) do add_foreign_key "lists", "boards", name: "fk_0d3f677137", on_delete: :cascade add_foreign_key "lists", "labels", name: "fk_7a5553d60f", on_delete: :cascade add_foreign_key "members", "users", name: "fk_2e88fb7ce9", on_delete: :cascade + add_foreign_key "merge_request_assignees", "merge_requests", on_delete: :cascade + add_foreign_key "merge_request_assignees", "users", on_delete: :cascade add_foreign_key "merge_request_diff_commits", "merge_request_diffs", on_delete: :cascade add_foreign_key "merge_request_diff_files", "merge_request_diffs", on_delete: :cascade add_foreign_key "merge_request_diffs", "merge_requests", name: "fk_8483f3258f", on_delete: :cascade -- cgit v1.2.3 From 4d84d1a850bc002e5d1269c360a5155bcc8fa243 Mon Sep 17 00:00:00 2001 From: Sanad Liaquat Date: Tue, 26 Mar 2019 16:39:52 +0500 Subject: Add seed for personal access token --- db/fixtures/development/25_api_personal_access_token.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/fixtures/development/25_api_personal_access_token.rb (limited to 'db') diff --git a/db/fixtures/development/25_api_personal_access_token.rb b/db/fixtures/development/25_api_personal_access_token.rb new file mode 100644 index 00000000000..a2e6c674c1f --- /dev/null +++ b/db/fixtures/development/25_api_personal_access_token.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require './spec/support/sidekiq' + +# Create an api access token for root user with the value: ypCa3Dzb23o5nvsixwPA +Gitlab::Seeder.quiet do + PersonalAccessToken.create!( + user_id: User.find_by(username: 'root').id, + name: "seeded-api-token", + scopes: ["api"], + token_digest: "/O0jfLERYT/L5gG8nfByQxqTj43TeLlRzOtJGTzRsbQ=" + ) + + print '.' +end -- cgit v1.2.3 From 1db3926dd2a5de719859ea962d4e1360b375d87b Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Fri, 15 Mar 2019 14:35:10 -0300 Subject: Add multi-line suggestion migrations Adds outdated, lines_above and lines_below columns to suggestions table. outdated - boolean which represents whether the suggestion is outdated or not. For instance, if any line changed after you left the multi-line suggestion, even though the note is not outdated, it helps tracking if the content has changed in the latest file. We cache this information in a column given it's not a cheap operation to do for every suggestion in the request time. lines_below, lines_above - persists the parsed arguments from `suggestion:-10+3` syntax, where `10` would be lines_above and 3 lines_below. We need that to dynamically calculate which lines we should monitor for outdating / persisting the correct content in from_content column. --- ...8192410_add_multi_line_attributes_to_suggestion.rb | 19 +++++++++++++++++++ db/schema.rb | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb (limited to 'db') diff --git a/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb b/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb new file mode 100644 index 00000000000..cdb898011e3 --- /dev/null +++ b/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddMultiLineAttributesToSuggestion < ActiveRecord::Migration[5.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false + add_column_with_default :suggestions, :lines_above, :integer, default: 0, allow_null: false + add_column_with_default :suggestions, :lines_below, :integer, default: 0, allow_null: false + end + + def down + remove_columns :suggestions, :outdated, :lines_above, :lines_below + end +end diff --git a/db/schema.rb b/db/schema.rb index 0c997f3b8a2..f34a776b2b0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2039,6 +2039,9 @@ ActiveRecord::Schema.define(version: 20190322132835) do t.string "commit_id" t.text "from_content", null: false t.text "to_content", null: false + t.boolean "outdated", default: false, null: false + t.integer "lines_above", default: 0, null: false + t.integer "lines_below", default: 0, null: false t.index ["note_id", "relative_order"], name: "index_suggestions_on_note_id_and_relative_order", unique: true, using: :btree end -- cgit v1.2.3 From 03e0604d5ded6402c7fddc4001ab23d9712c98de Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Fri, 15 Mar 2019 14:35:34 -0300 Subject: Prepare suggestion implementation for multi-line Adds the groundwork needed in order to persist multi-line suggestions, while providing the parsing strategy which will be reused for the **Preview** as well. --- db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb b/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb index cdb898011e3..856dfc89fa3 100644 --- a/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb +++ b/db/migrate/20190228192410_add_multi_line_attributes_to_suggestion.rb @@ -8,9 +8,9 @@ class AddMultiLineAttributesToSuggestion < ActiveRecord::Migration[5.0] disable_ddl_transaction! def up - add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false add_column_with_default :suggestions, :lines_above, :integer, default: 0, allow_null: false add_column_with_default :suggestions, :lines_below, :integer, default: 0, allow_null: false + add_column_with_default :suggestions, :outdated, :boolean, default: false, allow_null: false end def down diff --git a/db/schema.rb b/db/schema.rb index f34a776b2b0..06f9f5da10d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2039,9 +2039,9 @@ ActiveRecord::Schema.define(version: 20190322132835) do t.string "commit_id" t.text "from_content", null: false t.text "to_content", null: false - t.boolean "outdated", default: false, null: false t.integer "lines_above", default: 0, null: false t.integer "lines_below", default: 0, null: false + t.boolean "outdated", default: false, null: false t.index ["note_id", "relative_order"], name: "index_suggestions_on_note_id_and_relative_order", unique: true, using: :btree end -- cgit v1.2.3