From 601f50c6421f135b52f737a3b59baa32e6a8f1fd Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Mon, 27 Mar 2017 11:22:43 +0200 Subject: Add endpoint that returns a list of deployments that happened within last 8.hours add index created_at --- .../20170327091750_add_created_at_index_to_deployments.rb | 11 +++++++++++ db/schema.rb | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170327091750_add_created_at_index_to_deployments.rb (limited to 'db') diff --git a/db/migrate/20170327091750_add_created_at_index_to_deployments.rb b/db/migrate/20170327091750_add_created_at_index_to_deployments.rb new file mode 100644 index 00000000000..cc615208c41 --- /dev/null +++ b/db/migrate/20170327091750_add_created_at_index_to_deployments.rb @@ -0,0 +1,11 @@ +class AddCreatedAtIndexToDeployments < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_concurrent_index :deployments, :created_at + end +end diff --git a/db/schema.rb b/db/schema.rb index f476637ceb2..fe4c5c3f356 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170317203554) do +ActiveRecord::Schema.define(version: 20170327091750) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -346,6 +346,7 @@ ActiveRecord::Schema.define(version: 20170317203554) do t.string "on_stop" end + add_index "deployments", ["created_at"], name: "index_deployments_on_created_at", using: :btree add_index "deployments", ["project_id", "environment_id", "iid"], name: "index_deployments_on_project_id_and_environment_id_and_iid", using: :btree add_index "deployments", ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true, using: :btree -- cgit v1.2.1 From 5e2219db48719af5ca971f9222fffa7bd66cb6d8 Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Tue, 28 Mar 2017 15:54:02 +0200 Subject: Fix unreversible migration, and small rubocop warnings --- db/migrate/20170327091750_add_created_at_index_to_deployments.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170327091750_add_created_at_index_to_deployments.rb b/db/migrate/20170327091750_add_created_at_index_to_deployments.rb index cc615208c41..9cc35d08e1a 100644 --- a/db/migrate/20170327091750_add_created_at_index_to_deployments.rb +++ b/db/migrate/20170327091750_add_created_at_index_to_deployments.rb @@ -5,7 +5,11 @@ class AddCreatedAtIndexToDeployments < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :deployments, :created_at end + + def down + remove_index :deployments, :created_at + end end -- cgit v1.2.1 From acc807cd30a4b0005b552d67583b20538474a1f2 Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Wed, 12 Apr 2017 23:04:26 -0500 Subject: Add preferred_language column to users --- .../20170413035209_add_preferred_language_to_users.rb | 14 ++++++++++++++ db/schema.rb | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170413035209_add_preferred_language_to_users.rb (limited to 'db') diff --git a/db/migrate/20170413035209_add_preferred_language_to_users.rb b/db/migrate/20170413035209_add_preferred_language_to_users.rb new file mode 100644 index 00000000000..5dc128dbaea --- /dev/null +++ b/db/migrate/20170413035209_add_preferred_language_to_users.rb @@ -0,0 +1,14 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddPreferredLanguageToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_column_with_default :users, :preferred_language, :string, default: 'en' + end +end diff --git a/db/schema.rb b/db/schema.rb index 5689f7331dc..03ce1257088 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170408033905) do +ActiveRecord::Schema.define(version: 20170413035209) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1304,6 +1304,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false + t.string "preferred_language" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.1 From 1de135bc0408a871e3bfa8b0ba5aa81a7936bd01 Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Wed, 19 Apr 2017 23:19:24 -0500 Subject: Fix Rubocop complains plus some small refactor --- db/migrate/20170413035209_add_preferred_language_to_users.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170413035209_add_preferred_language_to_users.rb b/db/migrate/20170413035209_add_preferred_language_to_users.rb index 5dc128dbaea..6fe91656eeb 100644 --- a/db/migrate/20170413035209_add_preferred_language_to_users.rb +++ b/db/migrate/20170413035209_add_preferred_language_to_users.rb @@ -8,7 +8,11 @@ class AddPreferredLanguageToUsers < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_column_with_default :users, :preferred_language, :string, default: 'en' end + + def down + remove_column :users, :preferred_language + end end -- cgit v1.2.1 From 230608e92b3177ae13877f56eb6da051d938d7ed Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Tue, 25 Apr 2017 00:02:58 +0200 Subject: Remove concurrent index --- db/migrate/20170327091750_add_created_at_index_to_deployments.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170327091750_add_created_at_index_to_deployments.rb b/db/migrate/20170327091750_add_created_at_index_to_deployments.rb index 9cc35d08e1a..fd6ed499b80 100644 --- a/db/migrate/20170327091750_add_created_at_index_to_deployments.rb +++ b/db/migrate/20170327091750_add_created_at_index_to_deployments.rb @@ -10,6 +10,6 @@ class AddCreatedAtIndexToDeployments < ActiveRecord::Migration end def down - remove_index :deployments, :created_at + remove_concurrent_index :deployments, :created_at end end -- cgit v1.2.1 From 284d4f76fee9f593cb67f3f2978ad4f49ef03c13 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 28 Apr 2017 13:23:34 +0100 Subject: Attempted adding separate clientside_sentry settings --- db/schema.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index ff00951d5f6..592f1c253ea 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170424142900) do +ActiveRecord::Schema.define(version: 20170426175636) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -63,7 +63,6 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.boolean "shared_runners_enabled", default: true, null: false t.integer "max_artifacts_size", default: 100, null: false t.string "runners_registration_token" - t.integer "max_pages_size", default: 100, null: false t.boolean "require_two_factor_authentication", default: false t.integer "two_factor_grace_period", default: 48 t.boolean "metrics_enabled", default: false @@ -112,15 +111,16 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" + t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false t.string "default_artifacts_expire_in", default: "0", null: false t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false - t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" + t.integer "cached_markdown_version" end create_table "audit_events", force: :cascade do |t| @@ -731,8 +731,8 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.integer "visibility_level", default: 20, null: false t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" - t.text "description_html" t.boolean "lfs_enabled" + t.text "description_html" t.integer "parent_id" t.boolean "require_two_factor_authentication", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false @@ -965,9 +965,9 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" - t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" + t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.integer "cached_markdown_version" end @@ -1070,7 +1070,6 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.string "line_code" t.string "note_type" t.text "position" - t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree @@ -1320,10 +1319,10 @@ ActiveRecord::Schema.define(version: 20170424142900) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" - t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false + t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.1 From cb4b2e31a75e0f31e49f739c9008451d53908a0e Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 28 Apr 2017 13:42:26 +0100 Subject: Added migration --- ...170428123910_add_clientside_sentry_to_application_settings.rb | 9 +++++++++ db/schema.rb | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb new file mode 100644 index 00000000000..2b085b889eb --- /dev/null +++ b/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb @@ -0,0 +1,9 @@ +# rubocop:disable all +class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration + def change + change_table :application_settings do |t| + t.boolean :clientside_sentry_enabled, default: false + t.string :clientside_sentry_dsn + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 592f1c253ea..a9940be22ff 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170426175636) do +ActiveRecord::Schema.define(version: 20170428123910) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -121,6 +121,8 @@ ActiveRecord::Schema.define(version: 20170426175636) do t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" t.integer "cached_markdown_version" + t.boolean "clientside_sentry_enabled", default: false + t.string "clientside_sentry_dsn" end create_table "audit_events", force: :cascade do |t| @@ -296,6 +298,7 @@ ActiveRecord::Schema.define(version: 20170426175636) do t.boolean "locked", default: false, null: false end + add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree add_index "ci_runners", ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree add_index "ci_runners", ["token"], name: "index_ci_runners_on_token", using: :btree -- cgit v1.2.1 From 89eaeb11d2a29b28b04f6494545ee1368462c237 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 28 Apr 2017 16:04:07 +0100 Subject: Revert schema.db to master --- db/schema.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 81cd32e2d83..b938657a186 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -<<<<<<< HEAD -ActiveRecord::Schema.define(version: 20170428123910) do -======= ActiveRecord::Schema.define(version: 20170426181740) do ->>>>>>> origin/master # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -67,6 +63,7 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.boolean "shared_runners_enabled", default: true, null: false t.integer "max_artifacts_size", default: 100, null: false t.string "runners_registration_token" + t.integer "max_pages_size", default: 100, null: false t.boolean "require_two_factor_authentication", default: false t.integer "two_factor_grace_period", default: 48 t.boolean "metrics_enabled", default: false @@ -115,18 +112,15 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" - t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false t.string "default_artifacts_expire_in", default: "0", null: false t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false + t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" - t.integer "cached_markdown_version" - t.boolean "clientside_sentry_enabled", default: false - t.string "clientside_sentry_dsn" end create_table "audit_events", force: :cascade do |t| @@ -738,8 +732,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.integer "visibility_level", default: 20, null: false t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" - t.boolean "lfs_enabled" t.text "description_html" + t.boolean "lfs_enabled" t.integer "parent_id" t.boolean "require_two_factor_authentication", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false @@ -972,9 +966,9 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" + t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" - t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.integer "cached_markdown_version" end @@ -1077,6 +1071,7 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.string "line_code" t.string "note_type" t.text "position" + t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree @@ -1326,10 +1321,10 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" + t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false - t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.1 From eacf8b74c5f57bd594485b9fe20e91c933d8b9bb Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 28 Apr 2017 16:07:59 +0100 Subject: Applied schema update with patch --- db/schema.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index b938657a186..a9940be22ff 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170426181740) do +ActiveRecord::Schema.define(version: 20170428123910) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -63,7 +63,6 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.boolean "shared_runners_enabled", default: true, null: false t.integer "max_artifacts_size", default: 100, null: false t.string "runners_registration_token" - t.integer "max_pages_size", default: 100, null: false t.boolean "require_two_factor_authentication", default: false t.integer "two_factor_grace_period", default: 48 t.boolean "metrics_enabled", default: false @@ -112,15 +111,18 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" + t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false t.string "default_artifacts_expire_in", default: "0", null: false t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false - t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" + t.integer "cached_markdown_version" + t.boolean "clientside_sentry_enabled", default: false + t.string "clientside_sentry_dsn" end create_table "audit_events", force: :cascade do |t| @@ -732,8 +734,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.integer "visibility_level", default: 20, null: false t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" - t.text "description_html" t.boolean "lfs_enabled" + t.text "description_html" t.integer "parent_id" t.boolean "require_two_factor_authentication", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false @@ -966,9 +968,9 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" - t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" + t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.integer "cached_markdown_version" end @@ -1071,7 +1073,6 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.string "line_code" t.string "note_type" t.text "position" - t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree @@ -1321,10 +1322,10 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" - t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false + t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.1 From 6b6296e1cde034ed6a335890a44a2f7bc87d782d Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 28 Apr 2017 17:50:41 +0100 Subject: Reverted false schema diffs --- db/schema.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index a9940be22ff..06f1b079dbf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -63,6 +63,7 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "shared_runners_enabled", default: true, null: false t.integer "max_artifacts_size", default: 100, null: false t.string "runners_registration_token" + t.integer "max_pages_size", default: 100, null: false t.boolean "require_two_factor_authentication", default: false t.integer "two_factor_grace_period", default: 48 t.boolean "metrics_enabled", default: false @@ -111,16 +112,15 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" - t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false t.string "default_artifacts_expire_in", default: "0", null: false t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false + t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" - t.integer "cached_markdown_version" t.boolean "clientside_sentry_enabled", default: false t.string "clientside_sentry_dsn" end @@ -734,8 +734,8 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.integer "visibility_level", default: 20, null: false t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" - t.boolean "lfs_enabled" t.text "description_html" + t.boolean "lfs_enabled" t.integer "parent_id" t.boolean "require_two_factor_authentication", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false @@ -968,9 +968,9 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" + t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" - t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.integer "cached_markdown_version" end @@ -1073,6 +1073,7 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.string "line_code" t.string "note_type" t.text "position" + t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree @@ -1322,10 +1323,10 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" + t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false - t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.1 From 637ed8a21e9f9457d1b194f9c591a0813c20cc3e Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 28 Apr 2017 18:09:55 +0100 Subject: Added migration downtime tag --- .../20170428123910_add_clientside_sentry_to_application_settings.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'db') diff --git a/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb index 2b085b889eb..380060b18b3 100644 --- a/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb +++ b/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb @@ -1,5 +1,8 @@ # rubocop:disable all class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration + DOWNTIME = true + DOWNTIME_REASON = 'This migration requires downtime because we must add 2 new columns, 1 of which has a default value.' + def change change_table :application_settings do |t| t.boolean :clientside_sentry_enabled, default: false -- cgit v1.2.1 From f76a5abb3462a4bfeacca254c0cbda4f313d4ecd Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Mon, 3 Apr 2017 15:10:30 +0200 Subject: Add migration to rename all namespaces with forbidden name This is based on a migration in https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2073 Rename forbidden child namespaces --- ...70403121055_rename_forbidden_root_namespaces.rb | 247 +++++++++++++++++++++ ...0404152317_rename_forbidden_child_namespaces.rb | 242 ++++++++++++++++++++ ...20170405111106_rename_wildcard_project_names.rb | 85 +++++++ 3 files changed, 574 insertions(+) create mode 100644 db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb create mode 100644 db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb create mode 100644 db/post_migrate/20170405111106_rename_wildcard_project_names.rb (limited to 'db') diff --git a/db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb b/db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb new file mode 100644 index 00000000000..fb475cae465 --- /dev/null +++ b/db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb @@ -0,0 +1,247 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RenameForbiddenRootNamespaces < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + include Gitlab::ShellAdapter + disable_ddl_transaction! + + class Namespace < ActiveRecord::Base + self.table_name = 'namespaces' + belongs_to :parent, class_name: "Namespace" + has_one :route, as: :source, autosave: true + has_many :children, class_name: "Namespace", foreign_key: :parent_id + has_many :projects + belongs_to :owner, class_name: "User" + + def full_path + if route && route.path.present? + @full_path ||= route.path + else + update_route if persisted? + + build_full_path + end + end + + def build_full_path + if parent && path + parent.full_path + '/' + path + else + path + end + end + + def update_route + prepare_route + route.save + end + + def prepare_route + route || build_route(source: self) + route.path = build_full_path + route.name = build_full_name + @full_path = nil + @full_name = nil + end + + def build_full_name + if parent && name + parent.human_name + ' / ' + name + else + name + end + end + + def human_name + owner&.name + end + end + + class Route < ActiveRecord::Base + self.table_name = 'routes' + belongs_to :source, polymorphic: true + + validates :source, presence: true + + validates :path, + length: { within: 1..255 }, + presence: true, + uniqueness: { case_sensitive: false } + end + + class Project < ActiveRecord::Base + self.table_name = 'projects' + + def repository_storage_path + Gitlab.config.repositories.storages[repository_storage]['path'] + end + end + + DOWNTIME = false + DISALLOWED_PATHS = %w[ + api + autocomplete + search + member + explore + uploads + import + notification_settings + abuse_reports + invites + help + koding + health_check + jwt + oauth + sent_notifications + ] + + def up + DISALLOWED_PATHS.each do |path| + say "Renaming namespaces called #{path}" + forbidden_namespaces_with_path(path).each do |namespace| + rename_namespace(namespace) + end + end + end + + def down + # nothing to do + end + + def rename_namespace(namespace) + old_path = namespace.path + old_full_path = namespace.full_path + # Only remove the last occurrence of the path name to get the parent namespace path + namespace_path = remove_last_occurrence(old_full_path, old_path) + new_path = rename_path(namespace_path, old_path) + new_full_path = if namespace_path.present? + File.join(namespace_path, new_path) + else + new_path + end + + Namespace.where(id: namespace).update_all(path: new_path) # skips callbacks & validations + + replace_statement = replace_sql(Route.arel_table[:path], old_full_path, new_full_path) + + update_column_in_batches(:routes, :path, replace_statement) do |table, query| + query.where(Route.arel_table[:path].matches("#{old_full_path}%")) + end + + clear_cache_for_namespace(namespace) + + # tasks here are based on `Namespace#move_dir` + move_repositories(namespace, old_full_path, new_full_path) + move_namespace_folders(uploads_dir, old_full_path, new_full_path) if file_storage? + move_namespace_folders(pages_dir, old_full_path, new_full_path) + end + + # This will replace the first occurance of a string in a column with + # the replacement + # On postgresql we can use `regexp_replace` for that. + # On mysql we remove the pattern from the beginning of the string, and + # concatenate the remaining part tot the replacement. + def replace_sql(column, pattern, replacement) + if Gitlab::Database.mysql? + substr = Arel::Nodes::NamedFunction.new("substring", [column, pattern.to_s.size + 1]) + concat = Arel::Nodes::NamedFunction.new("concat", [Arel::Nodes::Quoted.new(replacement.to_s), substr]) + Arel::Nodes::SqlLiteral.new(concat.to_sql) + else + replace = Arel::Nodes::NamedFunction.new("regexp_replace", [column, Arel::Nodes::Quoted.new(pattern.to_s), Arel::Nodes::Quoted.new(replacement.to_s)]) + Arel::Nodes::SqlLiteral.new(replace.to_sql) + end + end + + def remove_last_occurrence(string, pattern) + string.reverse.sub(pattern.reverse, "").reverse + end + + def move_namespace_folders(directory, old_relative_path, new_relative_path) + old_path = File.join(directory, old_relative_path) + return unless File.directory?(old_path) + + new_path = File.join(directory, new_relative_path) + FileUtils.mv(old_path, new_path) + end + + def move_repositories(namespace, old_full_path, new_full_path) + repo_paths_for_namespace(namespace).each do |repository_storage_path| + # Ensure old directory exists before moving it + gitlab_shell.add_namespace(repository_storage_path, old_full_path) + + unless gitlab_shell.mv_namespace(repository_storage_path, old_full_path, new_full_path) + say "Exception moving path #{repository_storage_path} from #{old_full_path} to #{new_full_path}" + end + end + end + + def rename_path(namespace_path, path_was) + counter = 0 + path = "#{path_was}#{counter}" + + while route_exists?(File.join(namespace_path, path)) + counter += 1 + path = "#{path_was}#{counter}" + end + + path + end + + def route_exists?(full_path) + Route.where(Route.arel_table[:path].matches(full_path)).any? + end + + def forbidden_namespaces_with_path(name) + Namespace.where(arel_table[:path].matches(name).and(arel_table[:parent_id].eq(nil))) + end + + def clear_cache_for_namespace(namespace) + project_ids = project_ids_for_namespace(namespace) + scopes = { "Project" => { id: project_ids }, + "Issue" => { project_id: project_ids }, + "MergeRequest" => { target_project_id: project_ids }, + "Note" => { project_id: project_ids } } + + ClearDatabaseCacheWorker.perform_async(scopes) + rescue => e + Rails.logger.error ["Couldn't clear the markdown cache: #{e.message}", e.backtrace.join("\n")].join("\n") + end + + def project_ids_for_namespace(namespace) + namespace_ids = child_ids_for_parent(namespace, ids: [namespace.id]) + namespace_or_children = Project.arel_table[:namespace_id].in(namespace_ids) + Project.unscoped.where(namespace_or_children).pluck(:id) + end + + # This won't scale to huge trees, but it should do for a handful of namespaces + def child_ids_for_parent(namespace, ids: []) + namespace.children.each do |child| + ids << child.id + child_ids_for_parent(child, ids: ids) if child.children.any? + end + ids + end + + def repo_paths_for_namespace(namespace) + namespace.projects.unscoped.select('distinct(repository_storage)').to_a.map(&:repository_storage_path) + end + + def uploads_dir + File.join(Rails.root, "public", "uploads") + end + + def pages_dir + Settings.pages.path + end + + def file_storage? + CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File + end + + def arel_table + Namespace.arel_table + end +end diff --git a/db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb b/db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb new file mode 100644 index 00000000000..8b082a892d4 --- /dev/null +++ b/db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb @@ -0,0 +1,242 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RenameForbiddenChildNamespaces < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + include Gitlab::ShellAdapter + disable_ddl_transaction! + + class Namespace < ActiveRecord::Base + self.table_name = 'namespaces' + belongs_to :parent, class_name: "Namespace" + has_one :route, as: :source, autosave: true + has_many :children, class_name: "Namespace", foreign_key: :parent_id + has_many :projects + belongs_to :owner, class_name: "User" + + def full_path + if route && route.path.present? + @full_path ||= route.path + else + update_route if persisted? + + build_full_path + end + end + + def build_full_path + if parent && path + parent.full_path + '/' + path + else + path + end + end + + def update_route + prepare_route + route.save + end + + def prepare_route + route || build_route(source: self) + route.path = build_full_path + route.name = build_full_name + @full_path = nil + @full_name = nil + end + + def build_full_name + if parent && name + parent.human_name + ' / ' + name + else + name + end + end + + def human_name + owner&.name + end + end + + class Route < ActiveRecord::Base + self.table_name = 'routes' + belongs_to :source, polymorphic: true + + validates :source, presence: true + + validates :path, + length: { within: 1..255 }, + presence: true, + uniqueness: { case_sensitive: false } + end + + class Project < ActiveRecord::Base + self.table_name = 'projects' + + def repository_storage_path + Gitlab.config.repositories.storages[repository_storage]['path'] + end + end + + DOWNTIME = false + DISALLOWED_PATHS = %w[info git-upload-pack + git-receive-pack gitlab-lfs autocomplete_sources + templates avatar commit pages compare network snippets + services mattermost deploy_keys forks import merge_requests + branches merged_branches tags protected_branches variables + triggers pipelines environments cycle_analytics builds + hooks container_registry milestones labels issues + project_members group_links notes noteable boards todos + uploads runners runner_projects settings repository + transfer remove_fork archive unarchive housekeeping + toggle_star preview_markdown export remove_export + generate_new_export download_export activity + new_issue_address] + + def up + DISALLOWED_PATHS.each do |path| + say "Renaming namespaces called #{path}" + forbidden_namespaces_with_path(path).each do |namespace| + rename_namespace(namespace) + end + end + end + + def down + # nothing to do + end + + def rename_namespace(namespace) + old_path = namespace.path + old_full_path = namespace.full_path + # Only remove the last occurrence of the path name to get the parent namespace path + namespace_path = remove_last_occurrence(old_full_path, old_path) + new_path = rename_path(namespace_path, old_path) + new_full_path = if namespace_path.present? + File.join(namespace_path, new_path) + else + new_path + end + + Namespace.where(id: namespace).update_all(path: new_path) # skips callbacks & validations + + replace_statement = replace_sql(Route.arel_table[:path], old_full_path, new_full_path) + + update_column_in_batches(:routes, :path, replace_statement) do |table, query| + query.where(Route.arel_table[:path].matches("#{old_full_path}%")) + end + + clear_cache_for_namespace(namespace) + + # tasks here are based on `Namespace#move_dir` + move_repositories(namespace, old_full_path, new_full_path) + move_namespace_folders(uploads_dir, old_full_path, new_full_path) if file_storage? + move_namespace_folders(pages_dir, old_full_path, new_full_path) + end + + # This will replace the first occurance of a string in a column with + # the replacement + # On postgresql we can use `regexp_replace` for that. + # On mysql we remove the pattern from the beginning of the string, and + # concatenate the remaining part tot the replacement. + def replace_sql(column, pattern, replacement) + if Gitlab::Database.mysql? + substr = Arel::Nodes::NamedFunction.new("substring", [column, pattern.to_s.size + 1]) + concat = Arel::Nodes::NamedFunction.new("concat", [Arel::Nodes::Quoted.new(replacement.to_s), substr]) + Arel::Nodes::SqlLiteral.new(concat.to_sql) + else + replace = Arel::Nodes::NamedFunction.new("regexp_replace", [column, Arel::Nodes::Quoted.new(pattern.to_s), Arel::Nodes::Quoted.new(replacement.to_s)]) + Arel::Nodes::SqlLiteral.new(replace.to_sql) + end + end + + def remove_last_occurrence(string, pattern) + string.reverse.sub(pattern.reverse, "").reverse + end + + def move_namespace_folders(directory, old_relative_path, new_relative_path) + old_path = File.join(directory, old_relative_path) + return unless File.directory?(old_path) + + new_path = File.join(directory, new_relative_path) + FileUtils.mv(old_path, new_path) + end + + def move_repositories(namespace, old_full_path, new_full_path) + repo_paths_for_namespace(namespace).each do |repository_storage_path| + # Ensure old directory exists before moving it + gitlab_shell.add_namespace(repository_storage_path, old_full_path) + + unless gitlab_shell.mv_namespace(repository_storage_path, old_full_path, new_full_path) + say "Exception moving path #{repository_storage_path} from #{old_full_path} to #{new_full_path}" + end + end + end + + def rename_path(namespace_path, path_was) + counter = 0 + path = "#{path_was}#{counter}" + + while route_exists?(File.join(namespace_path, path)) + counter += 1 + path = "#{path_was}#{counter}" + end + + path + end + + def route_exists?(full_path) + Route.where(Route.arel_table[:path].matches(full_path)).any? + end + + def forbidden_namespaces_with_path(path) + Namespace.where(arel_table[:parent_id].eq(nil).not).where(arel_table[:path].matches(path)) + end + + def clear_cache_for_namespace(namespace) + project_ids = project_ids_for_namespace(namespace) + scopes = { "Project" => { id: project_ids }, + "Issue" => { project_id: project_ids }, + "MergeRequest" => { target_project_id: project_ids }, + "Note" => { project_id: project_ids } } + + ClearDatabaseCacheWorker.perform_async(scopes) + rescue => e + Rails.logger.error ["Couldn't clear the markdown cache: #{e.message}", e.backtrace.join("\n")].join("\n") + end + + def project_ids_for_namespace(namespace) + namespace_ids = child_ids_for_parent(namespace, ids: [namespace.id]) + namespace_or_children = Project.arel_table[:namespace_id].in(namespace_ids) + Project.unscoped.where(namespace_or_children).pluck(:id) + end + + # This won't scale to huge trees, but it should do for a handful of namespaces + def child_ids_for_parent(namespace, ids: []) + namespace.children.each do |child| + ids << child.id + child_ids_for_parent(child, ids: ids) if child.children.any? + end + ids + end + + def repo_paths_for_namespace(namespace) + namespace.projects.unscoped.select('distinct(repository_storage)').to_a.map(&:repository_storage_path) + end + + def uploads_dir + File.join(Rails.root, "public", "uploads") + end + + def pages_dir + Settings.pages.path + end + + def file_storage? + CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File + end + + def arel_table + Namespace.arel_table + end +end diff --git a/db/post_migrate/20170405111106_rename_wildcard_project_names.rb b/db/post_migrate/20170405111106_rename_wildcard_project_names.rb new file mode 100644 index 00000000000..1b8d2a40e99 --- /dev/null +++ b/db/post_migrate/20170405111106_rename_wildcard_project_names.rb @@ -0,0 +1,85 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RenameWildcardProjectNames < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + include Gitlab::ShellAdapter + disable_ddl_transaction! + + DOWNTIME = false + KNOWN_PATHS = %w[info git-upload-pack + git-receive-pack gitlab-lfs autocomplete_sources + templates avatar commit pages compare network snippets + services mattermost deploy_keys forks import merge_requests + branches merged_branches tags protected_branches variables + triggers pipelines environments cycle_analytics builds + hooks container_registry milestones labels issues + project_members group_links notes noteable boards todos + uploads runners runner_projects settings repository + transfer remove_fork archive unarchive housekeeping + toggle_star preview_markdown export remove_export + generate_new_export download_export activity + new_issue_address].freeze + + def up + reserved_projects.find_in_batches(batch_size: 100) do |slice| + rename_projects(slice) + end + end + + def down + # nothing to do here + end + + private + + def reserved_projects + Project.unscoped. + includes(:namespace). + where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)'). + where('projects.path' => KNOWN_PATHS) + end + + def route_exists?(full_path) + quoted_path = ActiveRecord::Base.connection.quote_string(full_path.downcase) + + ActiveRecord::Base.connection. + select_all("SELECT id, path FROM routes WHERE lower(path) = '#{quoted_path}'").present? + end + + # Adds number to the end of the path that is not taken by other route + def rename_path(namespace_path, path_was) + counter = 0 + path = "#{path_was}#{counter}" + + while route_exists?("#{namespace_path}/#{path}") + counter += 1 + path = "#{path_was}#{counter}" + end + + path + end + + def rename_projects(projects) + projects.each do |project| + id = project.id + path_was = project.path + namespace_path = project.namespace.path + path = rename_path(namespace_path, path_was) + + begin + # Because project path update is quite complex operation we can't safely + # copy-paste all code from GitLab. As exception we use Rails code here + project.rename_repo if rename_project_row(project, path) + rescue Exception => e # rubocop: disable Lint/RescueException + Rails.logger.error "Exception when renaming project #{id}: #{e.message}" + end + end + end + + def rename_project_row(project, path) + project.respond_to?(:update_attributes) && + project.update_attributes(path: path) && + project.respond_to?(:rename_repo) + end +end -- cgit v1.2.1 From e3d6957812e6cf399c208b1109ccc81ee1ff9144 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Wed, 12 Apr 2017 20:26:02 +0200 Subject: Rename forbidden paths in a single migration --- ...70403121055_rename_forbidden_root_namespaces.rb | 247 --------------------- ...0404152317_rename_forbidden_child_namespaces.rb | 242 -------------------- ...20170405111106_rename_wildcard_project_names.rb | 85 ------- ...20170412174900_rename_reserved_dynamic_paths.rb | 39 ++++ 4 files changed, 39 insertions(+), 574 deletions(-) delete mode 100644 db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb delete mode 100644 db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb delete mode 100644 db/post_migrate/20170405111106_rename_wildcard_project_names.rb create mode 100644 db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb (limited to 'db') diff --git a/db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb b/db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb deleted file mode 100644 index fb475cae465..00000000000 --- a/db/post_migrate/20170403121055_rename_forbidden_root_namespaces.rb +++ /dev/null @@ -1,247 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameForbiddenRootNamespaces < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - include Gitlab::ShellAdapter - disable_ddl_transaction! - - class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' - belongs_to :parent, class_name: "Namespace" - has_one :route, as: :source, autosave: true - has_many :children, class_name: "Namespace", foreign_key: :parent_id - has_many :projects - belongs_to :owner, class_name: "User" - - def full_path - if route && route.path.present? - @full_path ||= route.path - else - update_route if persisted? - - build_full_path - end - end - - def build_full_path - if parent && path - parent.full_path + '/' + path - else - path - end - end - - def update_route - prepare_route - route.save - end - - def prepare_route - route || build_route(source: self) - route.path = build_full_path - route.name = build_full_name - @full_path = nil - @full_name = nil - end - - def build_full_name - if parent && name - parent.human_name + ' / ' + name - else - name - end - end - - def human_name - owner&.name - end - end - - class Route < ActiveRecord::Base - self.table_name = 'routes' - belongs_to :source, polymorphic: true - - validates :source, presence: true - - validates :path, - length: { within: 1..255 }, - presence: true, - uniqueness: { case_sensitive: false } - end - - class Project < ActiveRecord::Base - self.table_name = 'projects' - - def repository_storage_path - Gitlab.config.repositories.storages[repository_storage]['path'] - end - end - - DOWNTIME = false - DISALLOWED_PATHS = %w[ - api - autocomplete - search - member - explore - uploads - import - notification_settings - abuse_reports - invites - help - koding - health_check - jwt - oauth - sent_notifications - ] - - def up - DISALLOWED_PATHS.each do |path| - say "Renaming namespaces called #{path}" - forbidden_namespaces_with_path(path).each do |namespace| - rename_namespace(namespace) - end - end - end - - def down - # nothing to do - end - - def rename_namespace(namespace) - old_path = namespace.path - old_full_path = namespace.full_path - # Only remove the last occurrence of the path name to get the parent namespace path - namespace_path = remove_last_occurrence(old_full_path, old_path) - new_path = rename_path(namespace_path, old_path) - new_full_path = if namespace_path.present? - File.join(namespace_path, new_path) - else - new_path - end - - Namespace.where(id: namespace).update_all(path: new_path) # skips callbacks & validations - - replace_statement = replace_sql(Route.arel_table[:path], old_full_path, new_full_path) - - update_column_in_batches(:routes, :path, replace_statement) do |table, query| - query.where(Route.arel_table[:path].matches("#{old_full_path}%")) - end - - clear_cache_for_namespace(namespace) - - # tasks here are based on `Namespace#move_dir` - move_repositories(namespace, old_full_path, new_full_path) - move_namespace_folders(uploads_dir, old_full_path, new_full_path) if file_storage? - move_namespace_folders(pages_dir, old_full_path, new_full_path) - end - - # This will replace the first occurance of a string in a column with - # the replacement - # On postgresql we can use `regexp_replace` for that. - # On mysql we remove the pattern from the beginning of the string, and - # concatenate the remaining part tot the replacement. - def replace_sql(column, pattern, replacement) - if Gitlab::Database.mysql? - substr = Arel::Nodes::NamedFunction.new("substring", [column, pattern.to_s.size + 1]) - concat = Arel::Nodes::NamedFunction.new("concat", [Arel::Nodes::Quoted.new(replacement.to_s), substr]) - Arel::Nodes::SqlLiteral.new(concat.to_sql) - else - replace = Arel::Nodes::NamedFunction.new("regexp_replace", [column, Arel::Nodes::Quoted.new(pattern.to_s), Arel::Nodes::Quoted.new(replacement.to_s)]) - Arel::Nodes::SqlLiteral.new(replace.to_sql) - end - end - - def remove_last_occurrence(string, pattern) - string.reverse.sub(pattern.reverse, "").reverse - end - - def move_namespace_folders(directory, old_relative_path, new_relative_path) - old_path = File.join(directory, old_relative_path) - return unless File.directory?(old_path) - - new_path = File.join(directory, new_relative_path) - FileUtils.mv(old_path, new_path) - end - - def move_repositories(namespace, old_full_path, new_full_path) - repo_paths_for_namespace(namespace).each do |repository_storage_path| - # Ensure old directory exists before moving it - gitlab_shell.add_namespace(repository_storage_path, old_full_path) - - unless gitlab_shell.mv_namespace(repository_storage_path, old_full_path, new_full_path) - say "Exception moving path #{repository_storage_path} from #{old_full_path} to #{new_full_path}" - end - end - end - - def rename_path(namespace_path, path_was) - counter = 0 - path = "#{path_was}#{counter}" - - while route_exists?(File.join(namespace_path, path)) - counter += 1 - path = "#{path_was}#{counter}" - end - - path - end - - def route_exists?(full_path) - Route.where(Route.arel_table[:path].matches(full_path)).any? - end - - def forbidden_namespaces_with_path(name) - Namespace.where(arel_table[:path].matches(name).and(arel_table[:parent_id].eq(nil))) - end - - def clear_cache_for_namespace(namespace) - project_ids = project_ids_for_namespace(namespace) - scopes = { "Project" => { id: project_ids }, - "Issue" => { project_id: project_ids }, - "MergeRequest" => { target_project_id: project_ids }, - "Note" => { project_id: project_ids } } - - ClearDatabaseCacheWorker.perform_async(scopes) - rescue => e - Rails.logger.error ["Couldn't clear the markdown cache: #{e.message}", e.backtrace.join("\n")].join("\n") - end - - def project_ids_for_namespace(namespace) - namespace_ids = child_ids_for_parent(namespace, ids: [namespace.id]) - namespace_or_children = Project.arel_table[:namespace_id].in(namespace_ids) - Project.unscoped.where(namespace_or_children).pluck(:id) - end - - # This won't scale to huge trees, but it should do for a handful of namespaces - def child_ids_for_parent(namespace, ids: []) - namespace.children.each do |child| - ids << child.id - child_ids_for_parent(child, ids: ids) if child.children.any? - end - ids - end - - def repo_paths_for_namespace(namespace) - namespace.projects.unscoped.select('distinct(repository_storage)').to_a.map(&:repository_storage_path) - end - - def uploads_dir - File.join(Rails.root, "public", "uploads") - end - - def pages_dir - Settings.pages.path - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end - - def arel_table - Namespace.arel_table - end -end diff --git a/db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb b/db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb deleted file mode 100644 index 8b082a892d4..00000000000 --- a/db/post_migrate/20170404152317_rename_forbidden_child_namespaces.rb +++ /dev/null @@ -1,242 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameForbiddenChildNamespaces < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - include Gitlab::ShellAdapter - disable_ddl_transaction! - - class Namespace < ActiveRecord::Base - self.table_name = 'namespaces' - belongs_to :parent, class_name: "Namespace" - has_one :route, as: :source, autosave: true - has_many :children, class_name: "Namespace", foreign_key: :parent_id - has_many :projects - belongs_to :owner, class_name: "User" - - def full_path - if route && route.path.present? - @full_path ||= route.path - else - update_route if persisted? - - build_full_path - end - end - - def build_full_path - if parent && path - parent.full_path + '/' + path - else - path - end - end - - def update_route - prepare_route - route.save - end - - def prepare_route - route || build_route(source: self) - route.path = build_full_path - route.name = build_full_name - @full_path = nil - @full_name = nil - end - - def build_full_name - if parent && name - parent.human_name + ' / ' + name - else - name - end - end - - def human_name - owner&.name - end - end - - class Route < ActiveRecord::Base - self.table_name = 'routes' - belongs_to :source, polymorphic: true - - validates :source, presence: true - - validates :path, - length: { within: 1..255 }, - presence: true, - uniqueness: { case_sensitive: false } - end - - class Project < ActiveRecord::Base - self.table_name = 'projects' - - def repository_storage_path - Gitlab.config.repositories.storages[repository_storage]['path'] - end - end - - DOWNTIME = false - DISALLOWED_PATHS = %w[info git-upload-pack - git-receive-pack gitlab-lfs autocomplete_sources - templates avatar commit pages compare network snippets - services mattermost deploy_keys forks import merge_requests - branches merged_branches tags protected_branches variables - triggers pipelines environments cycle_analytics builds - hooks container_registry milestones labels issues - project_members group_links notes noteable boards todos - uploads runners runner_projects settings repository - transfer remove_fork archive unarchive housekeeping - toggle_star preview_markdown export remove_export - generate_new_export download_export activity - new_issue_address] - - def up - DISALLOWED_PATHS.each do |path| - say "Renaming namespaces called #{path}" - forbidden_namespaces_with_path(path).each do |namespace| - rename_namespace(namespace) - end - end - end - - def down - # nothing to do - end - - def rename_namespace(namespace) - old_path = namespace.path - old_full_path = namespace.full_path - # Only remove the last occurrence of the path name to get the parent namespace path - namespace_path = remove_last_occurrence(old_full_path, old_path) - new_path = rename_path(namespace_path, old_path) - new_full_path = if namespace_path.present? - File.join(namespace_path, new_path) - else - new_path - end - - Namespace.where(id: namespace).update_all(path: new_path) # skips callbacks & validations - - replace_statement = replace_sql(Route.arel_table[:path], old_full_path, new_full_path) - - update_column_in_batches(:routes, :path, replace_statement) do |table, query| - query.where(Route.arel_table[:path].matches("#{old_full_path}%")) - end - - clear_cache_for_namespace(namespace) - - # tasks here are based on `Namespace#move_dir` - move_repositories(namespace, old_full_path, new_full_path) - move_namespace_folders(uploads_dir, old_full_path, new_full_path) if file_storage? - move_namespace_folders(pages_dir, old_full_path, new_full_path) - end - - # This will replace the first occurance of a string in a column with - # the replacement - # On postgresql we can use `regexp_replace` for that. - # On mysql we remove the pattern from the beginning of the string, and - # concatenate the remaining part tot the replacement. - def replace_sql(column, pattern, replacement) - if Gitlab::Database.mysql? - substr = Arel::Nodes::NamedFunction.new("substring", [column, pattern.to_s.size + 1]) - concat = Arel::Nodes::NamedFunction.new("concat", [Arel::Nodes::Quoted.new(replacement.to_s), substr]) - Arel::Nodes::SqlLiteral.new(concat.to_sql) - else - replace = Arel::Nodes::NamedFunction.new("regexp_replace", [column, Arel::Nodes::Quoted.new(pattern.to_s), Arel::Nodes::Quoted.new(replacement.to_s)]) - Arel::Nodes::SqlLiteral.new(replace.to_sql) - end - end - - def remove_last_occurrence(string, pattern) - string.reverse.sub(pattern.reverse, "").reverse - end - - def move_namespace_folders(directory, old_relative_path, new_relative_path) - old_path = File.join(directory, old_relative_path) - return unless File.directory?(old_path) - - new_path = File.join(directory, new_relative_path) - FileUtils.mv(old_path, new_path) - end - - def move_repositories(namespace, old_full_path, new_full_path) - repo_paths_for_namespace(namespace).each do |repository_storage_path| - # Ensure old directory exists before moving it - gitlab_shell.add_namespace(repository_storage_path, old_full_path) - - unless gitlab_shell.mv_namespace(repository_storage_path, old_full_path, new_full_path) - say "Exception moving path #{repository_storage_path} from #{old_full_path} to #{new_full_path}" - end - end - end - - def rename_path(namespace_path, path_was) - counter = 0 - path = "#{path_was}#{counter}" - - while route_exists?(File.join(namespace_path, path)) - counter += 1 - path = "#{path_was}#{counter}" - end - - path - end - - def route_exists?(full_path) - Route.where(Route.arel_table[:path].matches(full_path)).any? - end - - def forbidden_namespaces_with_path(path) - Namespace.where(arel_table[:parent_id].eq(nil).not).where(arel_table[:path].matches(path)) - end - - def clear_cache_for_namespace(namespace) - project_ids = project_ids_for_namespace(namespace) - scopes = { "Project" => { id: project_ids }, - "Issue" => { project_id: project_ids }, - "MergeRequest" => { target_project_id: project_ids }, - "Note" => { project_id: project_ids } } - - ClearDatabaseCacheWorker.perform_async(scopes) - rescue => e - Rails.logger.error ["Couldn't clear the markdown cache: #{e.message}", e.backtrace.join("\n")].join("\n") - end - - def project_ids_for_namespace(namespace) - namespace_ids = child_ids_for_parent(namespace, ids: [namespace.id]) - namespace_or_children = Project.arel_table[:namespace_id].in(namespace_ids) - Project.unscoped.where(namespace_or_children).pluck(:id) - end - - # This won't scale to huge trees, but it should do for a handful of namespaces - def child_ids_for_parent(namespace, ids: []) - namespace.children.each do |child| - ids << child.id - child_ids_for_parent(child, ids: ids) if child.children.any? - end - ids - end - - def repo_paths_for_namespace(namespace) - namespace.projects.unscoped.select('distinct(repository_storage)').to_a.map(&:repository_storage_path) - end - - def uploads_dir - File.join(Rails.root, "public", "uploads") - end - - def pages_dir - Settings.pages.path - end - - def file_storage? - CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File - end - - def arel_table - Namespace.arel_table - end -end diff --git a/db/post_migrate/20170405111106_rename_wildcard_project_names.rb b/db/post_migrate/20170405111106_rename_wildcard_project_names.rb deleted file mode 100644 index 1b8d2a40e99..00000000000 --- a/db/post_migrate/20170405111106_rename_wildcard_project_names.rb +++ /dev/null @@ -1,85 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class RenameWildcardProjectNames < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - include Gitlab::ShellAdapter - disable_ddl_transaction! - - DOWNTIME = false - KNOWN_PATHS = %w[info git-upload-pack - git-receive-pack gitlab-lfs autocomplete_sources - templates avatar commit pages compare network snippets - services mattermost deploy_keys forks import merge_requests - branches merged_branches tags protected_branches variables - triggers pipelines environments cycle_analytics builds - hooks container_registry milestones labels issues - project_members group_links notes noteable boards todos - uploads runners runner_projects settings repository - transfer remove_fork archive unarchive housekeeping - toggle_star preview_markdown export remove_export - generate_new_export download_export activity - new_issue_address].freeze - - def up - reserved_projects.find_in_batches(batch_size: 100) do |slice| - rename_projects(slice) - end - end - - def down - # nothing to do here - end - - private - - def reserved_projects - Project.unscoped. - includes(:namespace). - where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)'). - where('projects.path' => KNOWN_PATHS) - end - - def route_exists?(full_path) - quoted_path = ActiveRecord::Base.connection.quote_string(full_path.downcase) - - ActiveRecord::Base.connection. - select_all("SELECT id, path FROM routes WHERE lower(path) = '#{quoted_path}'").present? - end - - # Adds number to the end of the path that is not taken by other route - def rename_path(namespace_path, path_was) - counter = 0 - path = "#{path_was}#{counter}" - - while route_exists?("#{namespace_path}/#{path}") - counter += 1 - path = "#{path_was}#{counter}" - end - - path - end - - def rename_projects(projects) - projects.each do |project| - id = project.id - path_was = project.path - namespace_path = project.namespace.path - path = rename_path(namespace_path, path_was) - - begin - # Because project path update is quite complex operation we can't safely - # copy-paste all code from GitLab. As exception we use Rails code here - project.rename_repo if rename_project_row(project, path) - rescue Exception => e # rubocop: disable Lint/RescueException - Rails.logger.error "Exception when renaming project #{id}: #{e.message}" - end - end - end - - def rename_project_row(project, path) - project.respond_to?(:update_attributes) && - project.update_attributes(path: path) && - project.respond_to?(:rename_repo) - end -end diff --git a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb new file mode 100644 index 00000000000..fcab298eb09 --- /dev/null +++ b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb @@ -0,0 +1,39 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RenameReservedDynamicPaths < ActiveRecord::Migration + include Gitlab::Database::RenameReservedPathsMigration + + DOWNTIME = false + + disable_ddl_transaction! + + DISALLOWED_ROOT_PATHS = %w[ + api + autocomplete + member + explore + uploads + import + notification_settings + abuse_reports + invites + koding + health_check + jwt + oauth + sent_notifications + - + ] + + DISALLOWED_WILDCARD_PATHS = %w[objects folders file] + + def up + rename_root_paths(DISALLOWED_ROOT_PATHS) + rename_wildcard_paths(DISALLOWED_WILDCARD_PATHS) + end + + def down + # nothing to do + end +end -- cgit v1.2.1 From ab5f9027fb2a78f9c15b3f4d0fcd20ed998e5272 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Fri, 14 Apr 2017 20:07:34 +0200 Subject: Rename namespaces called `Users` This should rename the already created namespace that snuck trough because the validation was case sensitive --- db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'db') diff --git a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb index fcab298eb09..73a59ef0d74 100644 --- a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb +++ b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb @@ -24,6 +24,7 @@ class RenameReservedDynamicPaths < ActiveRecord::Migration oauth sent_notifications - + users ] DISALLOWED_WILDCARD_PATHS = %w[objects folders file] -- cgit v1.2.1 From 389057f00184a3549a1874174cbb81c807abfd49 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Tue, 18 Apr 2017 17:16:48 +0200 Subject: Rename Projects & Namespaces based on entire paths --- db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb index 73a59ef0d74..88eca39c716 100644 --- a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb +++ b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb @@ -27,7 +27,8 @@ class RenameReservedDynamicPaths < ActiveRecord::Migration users ] - DISALLOWED_WILDCARD_PATHS = %w[objects folders file] + DISALLOWED_WILDCARD_PATHS = %w[info/lfs/objects gitlab-lfs/objects + environments/folders] def up rename_root_paths(DISALLOWED_ROOT_PATHS) -- cgit v1.2.1 From 99a03fd6e912f594f96176f581de47e1731d3459 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Tue, 25 Apr 2017 14:10:04 +0200 Subject: Move ReservedPathsMigration into V1 namespace --- ...20170412174900_rename_reserved_dynamic_paths.rb | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'db') diff --git a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb index 88eca39c716..0fe04a23959 100644 --- a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb +++ b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb @@ -2,33 +2,36 @@ # for more information on how to write migrations for GitLab. class RenameReservedDynamicPaths < ActiveRecord::Migration - include Gitlab::Database::RenameReservedPathsMigration + include Gitlab::Database::RenameReservedPathsMigration::V1 DOWNTIME = false disable_ddl_transaction! DISALLOWED_ROOT_PATHS = %w[ + - + abuse_reports api autocomplete - member explore - uploads + health_check import - notification_settings - abuse_reports invites - koding - health_check jwt + koding + member + notification_settings oauth sent_notifications - - + uploads users ] - DISALLOWED_WILDCARD_PATHS = %w[info/lfs/objects gitlab-lfs/objects - environments/folders] + DISALLOWED_WILDCARD_PATHS = %w[ + environments/folders + gitlab-lfs/objects + info/lfs/objects + ] def up rename_root_paths(DISALLOWED_ROOT_PATHS) -- cgit v1.2.1 From 2e2a63c8669a084ed3a3aa5e770158ea2cb43a9d Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Sun, 30 Apr 2017 20:06:11 +0200 Subject: Rename child namespaces in migrationhelpers --- .../20170412174900_rename_reserved_dynamic_paths.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'db') diff --git a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb index 0fe04a23959..a23f83205f1 100644 --- a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb +++ b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb @@ -23,6 +23,7 @@ class RenameReservedDynamicPaths < ActiveRecord::Migration notification_settings oauth sent_notifications + unicorn_test uploads users ] @@ -33,9 +34,19 @@ class RenameReservedDynamicPaths < ActiveRecord::Migration info/lfs/objects ] + DISSALLOWED_GROUP_PATHS = %w[ + activity + avatar + group_members + labels + milestones + subgroups + ] + def up rename_root_paths(DISALLOWED_ROOT_PATHS) rename_wildcard_paths(DISALLOWED_WILDCARD_PATHS) + rename_child_paths(DISSALLOWED_GROUP_PATHS) end def down -- cgit v1.2.1 From 6d5364cfb0e39f49afac9b465f37bd19185c3755 Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Tue, 2 May 2017 23:36:36 -0500 Subject: First round of updates from the code review. --- db/migrate/20170413035209_add_preferred_language_to_users.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20170413035209_add_preferred_language_to_users.rb b/db/migrate/20170413035209_add_preferred_language_to_users.rb index 6fe91656eeb..92f1d6f2436 100644 --- a/db/migrate/20170413035209_add_preferred_language_to_users.rb +++ b/db/migrate/20170413035209_add_preferred_language_to_users.rb @@ -6,10 +6,8 @@ class AddPreferredLanguageToUsers < ActiveRecord::Migration DOWNTIME = false - disable_ddl_transaction! - def up - add_column_with_default :users, :preferred_language, :string, default: 'en' + add_column :users, :preferred_language, :string end def down -- cgit v1.2.1 From f3732e167b3d1ab58cbd49261ef7624959387cab Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 3 May 2017 14:51:53 +0100 Subject: [ci skip] Update migration to be reversible and use add_column_with_default --- ...dd_clientside_sentry_to_application_settings.rb | 37 ++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'db') diff --git a/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb index 380060b18b3..f3e08aed819 100644 --- a/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb +++ b/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb @@ -1,12 +1,31 @@ -# rubocop:disable all class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration - DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because we must add 2 new columns, 1 of which has a default value.' - - def change - change_table :application_settings do |t| - t.boolean :clientside_sentry_enabled, default: false - t.string :clientside_sentry_dsn - end + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + def up + add_column_with_default :application_settings, :clientside_sentry_enabled, :boolean, default: false + add_column :application_settings, :clientside_sentry_dsn, :string + end + + def down + remove_columns :application_settings, :clientside_sentry_enabled, :clientside_sentry_dsn end end -- cgit v1.2.1 From 555a3cf5bbfb78d697c70339bc65047d90e26d95 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 3 May 2017 14:53:46 +0100 Subject: Updated schema.rb with patch mode --- db/schema.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index c3fbb74e878..ea303678ac0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -63,7 +63,6 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "shared_runners_enabled", default: true, null: false t.integer "max_artifacts_size", default: 100, null: false t.string "runners_registration_token" - t.integer "max_pages_size", default: 100, null: false t.boolean "require_two_factor_authentication", default: false t.integer "two_factor_grace_period", default: 48 t.boolean "metrics_enabled", default: false @@ -112,16 +111,17 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" + t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false t.string "default_artifacts_expire_in", default: "0", null: false t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false - t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" - t.boolean "clientside_sentry_enabled", default: false + t.integer "cached_markdown_version" + t.boolean "clientside_sentry_enabled", default: false, null: false t.string "clientside_sentry_dsn" end @@ -735,8 +735,8 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.integer "visibility_level", default: 20, null: false t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" - t.text "description_html" t.boolean "lfs_enabled" + t.text "description_html" t.integer "parent_id" t.boolean "require_two_factor_authentication", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false @@ -969,9 +969,9 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" - t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" + t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.integer "cached_markdown_version" end @@ -1074,7 +1074,6 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.string "line_code" t.string "note_type" t.text "position" - t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree @@ -1324,10 +1323,10 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" - t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false + t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.1 From 1a168dc7a587182dc6bd39f543198ada21f87437 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 2 May 2017 10:17:48 +0100 Subject: Fix caching large snippet HTML content on MySQL databases --- db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb | 2 ++ db/migrate/markdown_cache_limits_to_mysql.rb | 13 +++++++++++++ db/schema.rb | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb create mode 100644 db/migrate/markdown_cache_limits_to_mysql.rb (limited to 'db') diff --git a/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb b/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb new file mode 100644 index 00000000000..008a94d8334 --- /dev/null +++ b/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb @@ -0,0 +1,2 @@ +# rubocop:disable all +require_relative 'markdown_cache_limits_to_mysql' diff --git a/db/migrate/markdown_cache_limits_to_mysql.rb b/db/migrate/markdown_cache_limits_to_mysql.rb new file mode 100644 index 00000000000..f6686db3dc0 --- /dev/null +++ b/db/migrate/markdown_cache_limits_to_mysql.rb @@ -0,0 +1,13 @@ +class MarkdownCacheLimitsToMysql < ActiveRecord::Migration + DOWNTIME = false + + def up + return unless Gitlab::Database.mysql? + + change_column :snippets, :content_html, :text, limit: 2147483647 + end + + def down + # no-op + end +end diff --git a/db/schema.rb b/db/schema.rb index be6684f3a6b..01c0f00c924 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170426181740) do +ActiveRecord::Schema.define(version: 20170502091007) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1 From 1faf398c5ddae576ef6b1aa63b7fed063c17d4f4 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 3 May 2017 16:46:18 +0100 Subject: Fixed schema diffs --- db/schema.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index ea303678ac0..97282e8f970 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -63,6 +63,7 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "shared_runners_enabled", default: true, null: false t.integer "max_artifacts_size", default: 100, null: false t.string "runners_registration_token" + t.integer "max_pages_size", default: 100, null: false t.boolean "require_two_factor_authentication", default: false t.integer "two_factor_grace_period", default: 48 t.boolean "metrics_enabled", default: false @@ -111,16 +112,15 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" - t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false t.string "default_artifacts_expire_in", default: "0", null: false t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false + t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" - t.integer "cached_markdown_version" t.boolean "clientside_sentry_enabled", default: false, null: false t.string "clientside_sentry_dsn" end @@ -735,8 +735,8 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.integer "visibility_level", default: 20, null: false t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" - t.boolean "lfs_enabled" t.text "description_html" + t.boolean "lfs_enabled" t.integer "parent_id" t.boolean "require_two_factor_authentication", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false @@ -969,9 +969,9 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" + t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" - t.integer "auto_cancel_pending_pipelines", default: 0, null: false t.integer "cached_markdown_version" end @@ -1074,6 +1074,7 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.string "line_code" t.string "note_type" t.text "position" + t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree @@ -1323,10 +1324,10 @@ ActiveRecord::Schema.define(version: 20170428123910) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" + t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false - t.date "last_activity_on" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.1 From 7ad5a1b371f5d319369a6b9d6609c40dea6292c2 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 3 May 2017 16:32:21 +1100 Subject: Add last_edited_at and last_edited_by attributes --- ...5_add_last_edited_at_and_last_edited_by_id_to_issues.rb | 14 ++++++++++++++ ...12_add_last_edited_at_and_last_edited_by_id_to_notes.rb | 14 ++++++++++++++ ...st_edited_at_and_last_edited_by_id_to_merge_requests.rb | 14 ++++++++++++++ db/schema.rb | 8 +++++++- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb create mode 100644 db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb create mode 100644 db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb (limited to 'db') diff --git a/db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb b/db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb new file mode 100644 index 00000000000..6ac10723c82 --- /dev/null +++ b/db/migrate/20170503021915_add_last_edited_at_and_last_edited_by_id_to_issues.rb @@ -0,0 +1,14 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddLastEditedAtAndLastEditedByIdToIssues < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + add_column :issues, :last_edited_at, :timestamp + add_column :issues, :last_edited_by_id, :integer + end +end diff --git a/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb b/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb new file mode 100644 index 00000000000..a44a1feab16 --- /dev/null +++ b/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb @@ -0,0 +1,14 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddLastEditedAtAndLastEditedByIdToNotes < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + add_column :notes, :last_edited_at, :timestamp + add_column :notes, :last_edited_by_id, :integer + end +end diff --git a/db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb b/db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb new file mode 100644 index 00000000000..7a1acdcbf69 --- /dev/null +++ b/db/migrate/20170503022548_add_last_edited_at_and_last_edited_by_id_to_merge_requests.rb @@ -0,0 +1,14 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddLastEditedAtAndLastEditedByIdToMergeRequests < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + add_column :merge_requests, :last_edited_at, :timestamp + add_column :merge_requests, :last_edited_by_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index be6684f3a6b..b173b467abf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170426181740) do +ActiveRecord::Schema.define(version: 20170503022548) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -488,6 +488,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.integer "relative_position" t.datetime "closed_at" t.integer "cached_markdown_version" + t.datetime "last_edited_at" + t.integer "last_edited_by_id" end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree @@ -674,6 +676,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.text "description_html" t.integer "time_estimate" t.integer "cached_markdown_version" + t.datetime "last_edited_at" + t.integer "last_edited_by_id" end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree @@ -774,6 +778,8 @@ ActiveRecord::Schema.define(version: 20170426181740) do t.string "discussion_id" t.text "note_html" t.integer "cached_markdown_version" + t.datetime "last_edited_at" + t.integer "last_edited_by_id" end add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree -- cgit v1.2.1 From 62be3355b1cc74e085a7a046e7aca05f59a1f97a Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 3 May 2017 22:11:19 +1100 Subject: Add alias_attributes for notes --- ...12_add_last_edited_at_and_last_edited_by_id_to_notes.rb | 14 -------------- db/schema.rb | 2 -- 2 files changed, 16 deletions(-) delete mode 100644 db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb (limited to 'db') diff --git a/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb b/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb deleted file mode 100644 index a44a1feab16..00000000000 --- a/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb +++ /dev/null @@ -1,14 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddLastEditedAtAndLastEditedByIdToNotes < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :notes, :last_edited_at, :timestamp - add_column :notes, :last_edited_by_id, :integer - end -end diff --git a/db/schema.rb b/db/schema.rb index b173b467abf..20127cbed32 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -778,8 +778,6 @@ ActiveRecord::Schema.define(version: 20170503022548) do t.string "discussion_id" t.text "note_html" t.integer "cached_markdown_version" - t.datetime "last_edited_at" - t.integer "last_edited_by_id" end add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree -- cgit v1.2.1 From dbd1bdaeed596f14af89d662e73030bb02571cfd Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Wed, 3 May 2017 21:05:38 -0500 Subject: More updates for translations plus some refactoring. --- db/fixtures/development/17_cycle_analytics.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 0d7eb1a7c93..040505ad52c 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -227,7 +227,7 @@ Gitlab::Seeder.quiet do if ENV[flag] Project.all.each do |project| - seeder = Gitlab::Seeder::CycleAnalytics.new(project) + seeder = Gitlab::Seeder::CycleAnalytics.new(pro) seeder.seed! end elsif ENV['CYCLE_ANALYTICS_PERF_TEST'] -- cgit v1.2.1 From 77bbc1c4af087d009fdfa3d7d4c9a720b7cc9c5b Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Thu, 4 May 2017 10:47:44 +0100 Subject: Reset schema and migration --- ...dd_clientside_sentry_to_application_settings.rb | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb new file mode 100644 index 00000000000..9462d858334 --- /dev/null +++ b/db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb @@ -0,0 +1,65 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index", "remove_concurrent_index" or + # "add_column_with_default" you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + # Reversability was tested when I made an update the originally irreversible + # migration after I ran it, so I could test that the down method worked and then + # the up method worked. + + def up + add_column_with_default :application_settings, :clientside_sentry_enabled, :boolean, default: false + add_column :application_settings, :clientside_sentry_dsn, :string + end + + def down + remove_columns :application_settings, :clientside_sentry_enabled, :clientside_sentry_dsn + end +end + +class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + +end -- cgit v1.2.1 From 1a8dc206a49a3812ce920ad94deda1ef57929c1b Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Thu, 4 May 2017 11:28:12 +0100 Subject: Reset migration to head --- ...dd_clientside_sentry_to_application_settings.rb | 31 ----------- ...dd_clientside_sentry_to_application_settings.rb | 65 ---------------------- db/schema.rb | 2 - 3 files changed, 98 deletions(-) delete mode 100644 db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb delete mode 100644 db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb deleted file mode 100644 index f3e08aed819..00000000000 --- a/db/migrate/20170428123910_add_clientside_sentry_to_application_settings.rb +++ /dev/null @@ -1,31 +0,0 @@ -class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # When a migration requires downtime you **must** uncomment the following - # constant and define a short and easy to understand explanation as to why the - # migration requires downtime. - # DOWNTIME_REASON = '' - - # When using the methods "add_concurrent_index" or "add_column_with_default" - # you must disable the use of transactions as these methods can not run in an - # existing transaction. When using "add_concurrent_index" make sure that this - # method is the _only_ method called in the migration, any other changes - # should go in a separate migration. This ensures that upon failure _only_ the - # index creation fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - def up - add_column_with_default :application_settings, :clientside_sentry_enabled, :boolean, default: false - add_column :application_settings, :clientside_sentry_dsn, :string - end - - def down - remove_columns :application_settings, :clientside_sentry_enabled, :clientside_sentry_dsn - end -end diff --git a/db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb deleted file mode 100644 index 9462d858334..00000000000 --- a/db/migrate/20170504094058_add_clientside_sentry_to_application_settings.rb +++ /dev/null @@ -1,65 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # When a migration requires downtime you **must** uncomment the following - # constant and define a short and easy to understand explanation as to why the - # migration requires downtime. - # DOWNTIME_REASON = '' - - # When using the methods "add_concurrent_index", "remove_concurrent_index" or - # "add_column_with_default" you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - # Reversability was tested when I made an update the originally irreversible - # migration after I ran it, so I could test that the down method worked and then - # the up method worked. - - def up - add_column_with_default :application_settings, :clientside_sentry_enabled, :boolean, default: false - add_column :application_settings, :clientside_sentry_dsn, :string - end - - def down - remove_columns :application_settings, :clientside_sentry_enabled, :clientside_sentry_dsn - end -end - -class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - # When a migration requires downtime you **must** uncomment the following - # constant and define a short and easy to understand explanation as to why the - # migration requires downtime. - # DOWNTIME_REASON = '' - - # When using the methods "add_concurrent_index" or "add_column_with_default" - # you must disable the use of transactions as these methods can not run in an - # existing transaction. When using "add_concurrent_index" make sure that this - # method is the _only_ method called in the migration, any other changes - # should go in a separate migration. This ensures that upon failure _only_ the - # index creation fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - disable_ddl_transaction! - - -end diff --git a/db/schema.rb b/db/schema.rb index 519a444833b..01c0f00c924 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -121,8 +121,6 @@ ActiveRecord::Schema.define(version: 20170502091007) do t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" - t.boolean "clientside_sentry_enabled", default: false, null: false - t.string "clientside_sentry_dsn" end create_table "audit_events", force: :cascade do |t| -- cgit v1.2.1 From 944ed8da556a067746ac6e98e2e81781748eab48 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Thu, 4 May 2017 11:32:28 +0100 Subject: clientside_sentry migration and schema changes commit --- ...dd_clientside_sentry_to_application_settings.rb | 33 ++++++++++++++++++++++ db/schema.rb | 4 ++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170504102911_add_clientside_sentry_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170504102911_add_clientside_sentry_to_application_settings.rb b/db/migrate/20170504102911_add_clientside_sentry_to_application_settings.rb new file mode 100644 index 00000000000..141112f8b50 --- /dev/null +++ b/db/migrate/20170504102911_add_clientside_sentry_to_application_settings.rb @@ -0,0 +1,33 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddClientsideSentryToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + def up + add_column_with_default :application_settings, :clientside_sentry_enabled, :boolean, default: false + add_column :application_settings, :clientside_sentry_dsn, :string + end + + def down + remove_columns :application_settings, :clientside_sentry_enabled, :clientside_sentry_dsn + end +end diff --git a/db/schema.rb b/db/schema.rb index 01c0f00c924..44148a9bc31 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170502091007) do +ActiveRecord::Schema.define(version: 20170504102911) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -121,6 +121,8 @@ ActiveRecord::Schema.define(version: 20170502091007) do t.integer "cached_markdown_version" t.boolean "usage_ping_enabled", default: true, null: false t.string "uuid" + t.boolean "clientside_sentry_enabled", default: false, null: false + t.string "clientside_sentry_dsn" end create_table "audit_events", force: :cascade do |t| -- cgit v1.2.1 From 387c4b2c21a44360386a9b8ce6849e7f1b8a3de9 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Thu, 4 May 2017 15:11:15 +0300 Subject: Backport of multiple_assignees_feature [ci skip] --- db/fixtures/development/09_issues.rb | 2 +- .../20170320171632_create_issue_assignees_table.rb | 40 +++++++++++++++++ db/migrate/20170320173259_migrate_assignees.rb | 52 ++++++++++++++++++++++ db/schema.rb | 10 +++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170320171632_create_issue_assignees_table.rb create mode 100644 db/migrate/20170320173259_migrate_assignees.rb (limited to 'db') diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb index d93d133d157..0b32a461d56 100644 --- a/db/fixtures/development/09_issues.rb +++ b/db/fixtures/development/09_issues.rb @@ -8,7 +8,7 @@ Gitlab::Seeder.quiet do description: FFaker::Lorem.sentence, state: ['opened', 'closed'].sample, milestone: project.milestones.sample, - assignee: project.team.users.sample + assignees: [project.team.users.sample] } Issues::CreateService.new(project, project.team.users.sample, issue_params).execute diff --git a/db/migrate/20170320171632_create_issue_assignees_table.rb b/db/migrate/20170320171632_create_issue_assignees_table.rb new file mode 100644 index 00000000000..72b70baa8d9 --- /dev/null +++ b/db/migrate/20170320171632_create_issue_assignees_table.rb @@ -0,0 +1,40 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateIssueAssigneesTable < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + INDEX_NAME = 'index_issue_assignees_on_issue_id_and_user_id' + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + + def up + create_table :issue_assignees, id: false do |t| + t.references :user, foreign_key: { on_delete: :cascade }, index: true, null: false + t.references :issue, foreign_key: { on_delete: :cascade }, null: false + end + + add_index :issue_assignees, [:issue_id, :user_id], unique: true, name: INDEX_NAME + end + + def down + drop_table :issue_assignees + end +end diff --git a/db/migrate/20170320173259_migrate_assignees.rb b/db/migrate/20170320173259_migrate_assignees.rb new file mode 100644 index 00000000000..ba8edbd7d32 --- /dev/null +++ b/db/migrate/20170320173259_migrate_assignees.rb @@ -0,0 +1,52 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class MigrateAssignees < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + def up + # Optimisation: this accounts for most of the invalid assignee IDs on GitLab.com + update_column_in_batches(:issues, :assignee_id, nil) do |table, query| + query.where(table[:assignee_id].eq(0)) + end + + users = Arel::Table.new(:users) + + update_column_in_batches(:issues, :assignee_id, nil) do |table, query| + query.where(table[:assignee_id].not_eq(nil)\ + .and( + users.project("true").where(users[:id].eq(table[:assignee_id])).exists.not + )) + end + + execute <<-EOF + INSERT INTO issue_assignees(issue_id, user_id) + SELECT id, assignee_id FROM issues WHERE assignee_id IS NOT NULL + EOF + end + + def down + execute <<-EOF + DELETE FROM issue_assignees + EOF + end +end diff --git a/db/schema.rb b/db/schema.rb index 01c0f00c924..340d4064c02 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -452,6 +452,14 @@ ActiveRecord::Schema.define(version: 20170502091007) do add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree + create_table "issue_assignees", id: false, force: :cascade do |t| + t.integer "user_id", null: false + t.integer "issue_id", null: false + end + + add_index "issue_assignees", ["issue_id", "user_id"], name: "index_issue_assignees_on_issue_id_and_user_id", unique: true, using: :btree + add_index "issue_assignees", ["user_id"], name: "index_issue_assignees_on_user_id", using: :btree + create_table "issue_metrics", force: :cascade do |t| t.integer "issue_id", null: false t.datetime "first_mentioned_in_commit_at" @@ -1383,6 +1391,8 @@ ActiveRecord::Schema.define(version: 20170502091007) do add_foreign_key "ci_trigger_requests", "ci_triggers", column: "trigger_id", name: "fk_b8ec8b7245", on_delete: :cascade add_foreign_key "ci_trigger_schedules", "ci_triggers", column: "trigger_id", name: "fk_90a406cc94", on_delete: :cascade add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade + add_foreign_key "issue_assignees", "issues", on_delete: :cascade + add_foreign_key "issue_assignees", "users", on_delete: :cascade add_foreign_key "container_repositories", "projects" add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade -- cgit v1.2.1 From 4b9eab02b8cc8bd443a802d1d73da26e5b3178d9 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Thu, 4 May 2017 18:11:31 +0200 Subject: Reject EE reserved namespace paths in CE as well --- db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'db') diff --git a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb index a23f83205f1..08cf366f0a1 100644 --- a/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb +++ b/db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb @@ -36,10 +36,17 @@ class RenameReservedDynamicPaths < ActiveRecord::Migration DISSALLOWED_GROUP_PATHS = %w[ activity + analytics + audit_events avatar group_members + hooks labels + ldap + ldap_group_links milestones + notification_setting + pipeline_quota subgroups ] -- cgit v1.2.1 From cdcbe99aa749d4516f47ca9d2e7d510dc29d1c91 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Wed, 3 May 2017 22:36:02 -0300 Subject: Add last_repository_updated_at to projects --- .../20170503004125_add_last_repository_updated_at_to_projects.rb | 7 +++++++ db/schema.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170503004125_add_last_repository_updated_at_to_projects.rb (limited to 'db') diff --git a/db/migrate/20170503004125_add_last_repository_updated_at_to_projects.rb b/db/migrate/20170503004125_add_last_repository_updated_at_to_projects.rb new file mode 100644 index 00000000000..00c685cf342 --- /dev/null +++ b/db/migrate/20170503004125_add_last_repository_updated_at_to_projects.rb @@ -0,0 +1,7 @@ +class AddLastRepositoryUpdatedAtToProjects < ActiveRecord::Migration + DOWNTIME = false + + def change + add_column :projects, :last_repository_updated_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 01c0f00c924..e12c6e30d8e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170502091007) do +ActiveRecord::Schema.define(version: 20170503004125) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -971,6 +971,7 @@ ActiveRecord::Schema.define(version: 20170502091007) do t.boolean "printing_merge_request_link_enabled", default: true, null: false t.string "import_jid" t.integer "cached_markdown_version" + t.datetime "last_repository_updated_at" end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree -- cgit v1.2.1 From 341964da45460d5c6593d0e08178ecf61e726e91 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Wed, 3 May 2017 22:37:43 -0300 Subject: Add index to last_repository_updated_at on projects --- ...add_index_to_last_repository_updated_at_on_projects.rb | 15 +++++++++++++++ db/schema.rb | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170503004425_add_index_to_last_repository_updated_at_on_projects.rb (limited to 'db') diff --git a/db/migrate/20170503004425_add_index_to_last_repository_updated_at_on_projects.rb b/db/migrate/20170503004425_add_index_to_last_repository_updated_at_on_projects.rb new file mode 100644 index 00000000000..6144d74745c --- /dev/null +++ b/db/migrate/20170503004425_add_index_to_last_repository_updated_at_on_projects.rb @@ -0,0 +1,15 @@ +class AddIndexToLastRepositoryUpdatedAtOnProjects < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index(:projects, :last_repository_updated_at) + end + + def down + remove_concurrent_index(:projects, :last_repository_updated_at) if index_exists?(:projects, :last_repository_updated_at) + end +end diff --git a/db/schema.rb b/db/schema.rb index e12c6e30d8e..5d3e22d6123 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170503004125) do +ActiveRecord::Schema.define(version: 20170503004425) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -980,6 +980,7 @@ ActiveRecord::Schema.define(version: 20170503004125) do add_index "projects", ["description"], name: "index_projects_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree add_index "projects", ["last_repository_check_failed"], name: "index_projects_on_last_repository_check_failed", using: :btree + add_index "projects", ["last_repository_updated_at"], name: "index_projects_on_last_repository_updated_at", using: :btree add_index "projects", ["name"], name: "index_projects_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} add_index "projects", ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree add_index "projects", ["path"], name: "index_projects_on_path", using: :btree -- cgit v1.2.1 From f7b7a520920204d1a2864af6d911ef9dc8c2df6b Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Thu, 4 May 2017 17:05:14 -0500 Subject: More updates for translations plus small tweaks. --- db/fixtures/development/17_cycle_analytics.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 040505ad52c..0d7eb1a7c93 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -227,7 +227,7 @@ Gitlab::Seeder.quiet do if ENV[flag] Project.all.each do |project| - seeder = Gitlab::Seeder::CycleAnalytics.new(pro) + seeder = Gitlab::Seeder::CycleAnalytics.new(project) seeder.seed! end elsif ENV['CYCLE_ANALYTICS_PERF_TEST'] -- cgit v1.2.1 From 34be1835af2913c86bc468131e6bcbd530daf48d Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 5 May 2017 13:41:35 +0300 Subject: [Multiple issue assignee] Fix a number of specs --- db/migrate/20170320171632_create_issue_assignees_table.rb | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170320171632_create_issue_assignees_table.rb b/db/migrate/20170320171632_create_issue_assignees_table.rb index 72b70baa8d9..23b8da37b6d 100644 --- a/db/migrate/20170320171632_create_issue_assignees_table.rb +++ b/db/migrate/20170320171632_create_issue_assignees_table.rb @@ -26,7 +26,7 @@ class CreateIssueAssigneesTable < ActiveRecord::Migration # disable_ddl_transaction! def up - create_table :issue_assignees, id: false do |t| + create_table :issue_assignees do |t| t.references :user, foreign_key: { on_delete: :cascade }, index: true, null: false t.references :issue, foreign_key: { on_delete: :cascade }, null: false end diff --git a/db/schema.rb b/db/schema.rb index 340d4064c02..7b960f79c1f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -452,7 +452,7 @@ ActiveRecord::Schema.define(version: 20170502091007) do add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree - create_table "issue_assignees", id: false, force: :cascade do |t| + create_table "issue_assignees", force: :cascade do |t| t.integer "user_id", null: false t.integer "issue_id", null: false end -- cgit v1.2.1 From 7d02bcd2e0165a90a9f2c1edb34b064ff76afd69 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Mon, 1 May 2017 13:46:30 -0700 Subject: Redirect from redirect routes to canonical routes --- db/migrate/20170427215854_create_redirect_routes.rb | 15 +++++++++++++++ db/schema.rb | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 db/migrate/20170427215854_create_redirect_routes.rb (limited to 'db') diff --git a/db/migrate/20170427215854_create_redirect_routes.rb b/db/migrate/20170427215854_create_redirect_routes.rb new file mode 100644 index 00000000000..57b79a0267f --- /dev/null +++ b/db/migrate/20170427215854_create_redirect_routes.rb @@ -0,0 +1,15 @@ +class CreateRedirectRoutes < ActiveRecord::Migration + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def change + create_table :redirect_routes do |t| + t.integer :source_id, null: false + t.string :source_type, null: false + t.string :path, null: false + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 588e2082ae0..3a8970b2235 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1040,6 +1040,14 @@ ActiveRecord::Schema.define(version: 20170504102911) do add_index "protected_tags", ["project_id"], name: "index_protected_tags_on_project_id", using: :btree + create_table "redirect_routes", force: :cascade do |t| + t.integer "source_id", null: false + t.string "source_type", null: false + t.string "path", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "releases", force: :cascade do |t| t.string "tag" t.text "description" -- cgit v1.2.1 From 4da848ef28fb9ff247145670a107dff82c83b270 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Wed, 3 May 2017 11:49:17 -0700 Subject: Add index for source association and for path --- .../20170503184421_add_index_to_redirect_routes.rb | 22 ++++++++++++++++++++++ db/schema.rb | 5 ++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170503184421_add_index_to_redirect_routes.rb (limited to 'db') diff --git a/db/migrate/20170503184421_add_index_to_redirect_routes.rb b/db/migrate/20170503184421_add_index_to_redirect_routes.rb new file mode 100644 index 00000000000..5991f6ab6a1 --- /dev/null +++ b/db/migrate/20170503184421_add_index_to_redirect_routes.rb @@ -0,0 +1,22 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +# rubocop:disable RemoveIndex +class AddIndexToRedirectRoutes < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index(:redirect_routes, :path, unique: true) + add_concurrent_index(:redirect_routes, [:source_type, :source_id]) + end + + def down + remove_index(:redirect_routes, :path) if index_exists?(:redirect_routes, :path) + remove_index(:redirect_routes, [:source_type, :source_id]) if index_exists?(:redirect_routes, [:source_type, :source_id]) + end +end diff --git a/db/schema.rb b/db/schema.rb index 3a8970b2235..45c3b9a4c91 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1048,6 +1048,9 @@ ActiveRecord::Schema.define(version: 20170504102911) do t.datetime "updated_at", null: false end + add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree + add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree + create_table "releases", force: :cascade do |t| t.string "tag" t.text "description" @@ -1423,4 +1426,4 @@ ActiveRecord::Schema.define(version: 20170504102911) do add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade add_foreign_key "trending_projects", "projects", on_delete: :cascade add_foreign_key "u2f_registrations", "users" -end \ No newline at end of file +end -- cgit v1.2.1 From 03144e1c0f2ba41a7570850b69d5029bc2619fd2 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Wed, 3 May 2017 12:00:52 -0700 Subject: Index redirect_routes path for LIKE --- ...03185032_index_redirect_routes_path_for_like.rb | 29 ++++++++++++++++++++++ db/schema.rb | 1 + 2 files changed, 30 insertions(+) create mode 100644 db/migrate/20170503185032_index_redirect_routes_path_for_like.rb (limited to 'db') diff --git a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb new file mode 100644 index 00000000000..5b8b6c828be --- /dev/null +++ b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb @@ -0,0 +1,29 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class IndexRedirectRoutesPathForLike < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + INDEX_NAME = 'index_redirect_routes_on_path_text_pattern_ops' + + disable_ddl_transaction! + + def up + return unless Gitlab::Database.postgresql? + + unless index_exists?(:redirect_routes, :path, name: INDEX_NAME) + execute("CREATE INDEX CONCURRENTLY #{INDEX_NAME} ON redirect_routes (path varchar_pattern_ops);") + end + end + + def down + return unless Gitlab::Database.postgresql? + + if index_exists?(:redirect_routes, :path, name: INDEX_NAME) + execute("DROP INDEX CONCURRENTLY #{INDEX_NAME};") + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 45c3b9a4c91..8d3f4b4bd36 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1049,6 +1049,7 @@ ActiveRecord::Schema.define(version: 20170504102911) do end add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree + add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree create_table "releases", force: :cascade do |t| -- cgit v1.2.1 From fc061c2ecd2e292383017c703220bfb22d0d6dce Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Wed, 3 May 2017 12:01:44 -0700 Subject: Fix Rubocop failures --- db/migrate/20170427215854_create_redirect_routes.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170427215854_create_redirect_routes.rb b/db/migrate/20170427215854_create_redirect_routes.rb index 57b79a0267f..2bf086b3e30 100644 --- a/db/migrate/20170427215854_create_redirect_routes.rb +++ b/db/migrate/20170427215854_create_redirect_routes.rb @@ -1,5 +1,4 @@ class CreateRedirectRoutes < ActiveRecord::Migration - # Set this constant to true if this migration requires downtime. DOWNTIME = false -- cgit v1.2.1 From 0c866f4a575d8127efbf3eafda83d8ccfbd97817 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Wed, 3 May 2017 15:26:44 -0700 Subject: Resolve discussions --- db/migrate/20170503184421_add_index_to_redirect_routes.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20170503184421_add_index_to_redirect_routes.rb b/db/migrate/20170503184421_add_index_to_redirect_routes.rb index 5991f6ab6a1..9062cf19a73 100644 --- a/db/migrate/20170503184421_add_index_to_redirect_routes.rb +++ b/db/migrate/20170503184421_add_index_to_redirect_routes.rb @@ -1,7 +1,6 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. -# rubocop:disable RemoveIndex class AddIndexToRedirectRoutes < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers @@ -16,7 +15,7 @@ class AddIndexToRedirectRoutes < ActiveRecord::Migration end def down - remove_index(:redirect_routes, :path) if index_exists?(:redirect_routes, :path) - remove_index(:redirect_routes, [:source_type, :source_id]) if index_exists?(:redirect_routes, [:source_type, :source_id]) + remove_concurrent_index(:redirect_routes, :path) if index_exists?(:redirect_routes, :path) + remove_concurrent_index(:redirect_routes, [:source_type, :source_id]) if index_exists?(:redirect_routes, [:source_type, :source_id]) end end -- cgit v1.2.1