From d2d30cff552e08c4b7ec2b5e23acced8eb29cbcb Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 14 Feb 2017 18:00:37 +0800 Subject: Initial implementation for default artifacts expiration TODO: Add tests and screenshots --- ...dd_default_artifacts_expiration_to_application_settings.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb new file mode 100644 index 00000000000..728d581251c --- /dev/null +++ b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb @@ -0,0 +1,11 @@ +class AddDefaultArtifactsExpirationToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :application_settings, + :default_artifacts_expiration, + :integer, default: 0, null: false + end +end -- cgit v1.2.3 From 53c94f9ea25c9d6a25b58a01db5f855f0719dbf4 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 14 Feb 2017 22:54:46 +0800 Subject: Use the same syntax for default expiration Feedback: * https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9219#note_23343951 * https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9219#note_23344036 * https://gitlab.com/gitlab-org/gitlab-ce/issues/27762#note_23344797 --- ...084746_add_default_artifacts_expiration_to_application_settings.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb index 728d581251c..34905570739 100644 --- a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb +++ b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb @@ -5,7 +5,7 @@ class AddDefaultArtifactsExpirationToApplicationSettings < ActiveRecord::Migrati def change add_column :application_settings, - :default_artifacts_expiration, - :integer, default: 0, null: false + :default_artifacts_expire_in, + :string, null: true end end -- cgit v1.2.3 From 297dc70158f905fef4557d1ee6510bcf459a08a9 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Thu, 2 Feb 2017 15:04:02 +0100 Subject: Create MM team for GitLab group --- db/migrate/20170120131253_create_chat_teams.rb | 17 +++++++++++++++++ db/schema.rb | 11 +++++++++++ 2 files changed, 28 insertions(+) create mode 100644 db/migrate/20170120131253_create_chat_teams.rb (limited to 'db') diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb new file mode 100644 index 00000000000..6476c239152 --- /dev/null +++ b/db/migrate/20170120131253_create_chat_teams.rb @@ -0,0 +1,17 @@ +class CreateChatTeams < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :chat_teams do |t| + t.integer :namespace_id, index: true + t.string :team_id + t.string :name + + t.timestamps null: false + end + + add_foreign_key :chat_teams, :namespaces, on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index 52672406ec6..0ae208fb5e4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -171,6 +171,16 @@ ActiveRecord::Schema.define(version: 20170214111112) do add_index "chat_names", ["service_id", "team_id", "chat_id"], name: "index_chat_names_on_service_id_and_team_id_and_chat_id", unique: true, using: :btree add_index "chat_names", ["user_id", "service_id"], name: "index_chat_names_on_user_id_and_service_id", unique: true, using: :btree + create_table "chat_teams", force: :cascade do |t| + t.integer "namespace_id" + t.string "team_id" + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "chat_teams", ["namespace_id"], name: "index_chat_teams_on_namespace_id", using: :btree + create_table "ci_application_settings", force: :cascade do |t| t.boolean "all_broken_builds" t.boolean "add_pusher" @@ -1330,6 +1340,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree add_foreign_key "boards", "projects" + add_foreign_key "chat_teams", "namespaces", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade -- cgit v1.2.3 From 8ddbc43576c1cebd652d6f3541574f0176794510 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Tue, 7 Feb 2017 08:24:57 +0100 Subject: Improve DRYness of views --- db/migrate/20170120131253_create_chat_teams.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb index 6476c239152..8f76b43960b 100644 --- a/db/migrate/20170120131253_create_chat_teams.rb +++ b/db/migrate/20170120131253_create_chat_teams.rb @@ -5,13 +5,13 @@ class CreateChatTeams < ActiveRecord::Migration def change create_table :chat_teams do |t| - t.integer :namespace_id, index: true + t.integer :group_id, index: true t.string :team_id t.string :name t.timestamps null: false end - add_foreign_key :chat_teams, :namespaces, on_delete: :cascade + add_foreign_key :chat_teams, :groups, on_delete: :cascade end end -- cgit v1.2.3 From 3acf4fbe3b6e96ac4bc438e24030fde076832b51 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 16 Feb 2017 11:00:35 +0000 Subject: Update schema --- db/schema.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 52672406ec6..b11792d14f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -111,6 +111,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do 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", limit: 255 end create_table "audit_events", force: :cascade do |t| -- cgit v1.2.3 From eede4ab1a2509ef4aa14d21527386224c4116adc Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 16 Feb 2017 23:40:13 +0800 Subject: 0 for unlimited, disallow blank, feedback: https://gitlab.com/gitlab-org/gitlab-ce/issues/27762#note_23520780 --- ...084746_add_default_artifacts_expiration_to_application_settings.rb | 4 ++-- db/schema.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb index 34905570739..e0e3ff8957a 100644 --- a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb +++ b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb @@ -5,7 +5,7 @@ class AddDefaultArtifactsExpirationToApplicationSettings < ActiveRecord::Migrati def change add_column :application_settings, - :default_artifacts_expire_in, - :string, null: true + :default_artifacts_expire_in, :string, + null: false, default: '0' end end diff --git a/db/schema.rb b/db/schema.rb index b11792d14f5..29ba7167bfa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -111,7 +111,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do 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", limit: 255 + t.string "default_artifacts_expire_in", default: '0', null: false end create_table "audit_events", force: :cascade do |t| @@ -1352,4 +1352,4 @@ ActiveRecord::Schema.define(version: 20170214111112) 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.3 From ac868482a7780a332045ef270a409ff70bcf8efd Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 1 Feb 2017 12:41:01 -0600 Subject: Allow issues in boards to be ordered --- ...170131221752_add_relative_position_to_issues.rb | 31 ++++++++++++++++++ db/schema.rb | 37 +++++++++++++++------- 2 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 db/migrate/20170131221752_add_relative_position_to_issues.rb (limited to 'db') diff --git a/db/migrate/20170131221752_add_relative_position_to_issues.rb b/db/migrate/20170131221752_add_relative_position_to_issues.rb new file mode 100644 index 00000000000..41e17cf13ba --- /dev/null +++ b/db/migrate/20170131221752_add_relative_position_to_issues.rb @@ -0,0 +1,31 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddRelativePositionToIssues < 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 change + add_column :issues, :relative_position, :float + + add_index :issues, :relative_position + end +end diff --git a/db/schema.rb b/db/schema.rb index 52672406ec6..545dd4ad7c0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -87,9 +87,9 @@ ActiveRecord::Schema.define(version: 20170214111112) do t.boolean "send_user_confirmation_email", default: false t.integer "container_registry_token_expire_delay", default: 5 t.text "after_sign_up_text" - t.boolean "user_default_external", default: false, null: false t.string "repository_storages", default: "default" t.string "enabled_git_access_protocol" + t.boolean "user_default_external", default: false, null: false t.boolean "domain_blacklist_enabled", default: false t.text "domain_blacklist" t.boolean "koding_enabled" @@ -402,22 +402,22 @@ ActiveRecord::Schema.define(version: 20170214111112) do add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree create_table "deployments", force: :cascade do |t| - t.integer "iid", null: false - t.integer "project_id", null: false - t.integer "environment_id", null: false - t.string "ref", null: false - t.boolean "tag", null: false - t.string "sha", null: false + t.integer "iid" + t.integer "project_id" + t.integer "environment_id" + t.string "ref" + t.boolean "tag" + t.string "sha" t.integer "user_id" - t.integer "deployable_id" - t.string "deployable_type" + t.integer "deployable_id", null: false + t.string "deployable_type", null: false t.datetime "created_at" t.datetime "updated_at" t.string "on_stop" end 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 + add_index "deployments", ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", using: :btree create_table "emails", force: :cascade do |t| t.integer "user_id", null: false @@ -514,6 +514,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do t.text "title_html" t.text "description_html" t.integer "time_estimate" + t.float "relative_position" end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree @@ -525,6 +526,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do add_index "issues", ["due_date"], name: "index_issues_on_due_date", using: :btree add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree add_index "issues", ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree + add_index "issues", ["relative_position"], name: "index_issues_on_relative_position", using: :btree add_index "issues", ["state"], name: "index_issues_on_state", using: :btree add_index "issues", ["title"], name: "index_issues_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} @@ -692,8 +694,8 @@ ActiveRecord::Schema.define(version: 20170214111112) do t.integer "merge_user_id" t.string "merge_commit_sha" t.datetime "deleted_at" - t.string "in_progress_merge_commit_sha" t.integer "lock_version" + t.string "in_progress_merge_commit_sha" t.text "title_html" t.text "description_html" t.integer "time_estimate" @@ -770,6 +772,16 @@ ActiveRecord::Schema.define(version: 20170214111112) do add_index "namespaces", ["path"], name: "index_namespaces_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree + create_table "note_templates", force: :cascade do |t| + t.integer "user_id" + t.string "title" + t.text "note" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "note_templates", ["user_id"], name: "index_note_templates_on_user_id", using: :btree + create_table "notes", force: :cascade do |t| t.text "note" t.string "noteable_type" @@ -785,6 +797,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do t.text "st_diff" t.integer "updated_by_id" t.string "type" + t.string "system_type" t.text "position" t.text "original_position" t.datetime "resolved_at" @@ -978,7 +991,7 @@ ActiveRecord::Schema.define(version: 20170214111112) do t.boolean "has_external_wiki" t.boolean "lfs_enabled" t.text "description_html" - t.boolean "only_allow_merge_if_all_discussions_are_resolved" + t.boolean "only_allow_merge_if_all_discussions_are_resolved", default: false, null: false end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree -- cgit v1.2.3 From 22d6f96cf982765fa9b957905248a573c6e3c498 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 16 Feb 2017 22:19:24 +0800 Subject: Add index for ci_commits for gl_project_id, ref, status and remove the old one which we don't really need. --- .../20170216135621_add_index_for_latest_successful_pipeline.rb | 10 ++++++++++ .../20170216141440_drop_index_for_builds_project_status.rb | 8 ++++++++ db/schema.rb | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb create mode 100644 db/migrate/20170216141440_drop_index_for_builds_project_status.rb (limited to 'db') diff --git a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb new file mode 100644 index 00000000000..7b1e687977b --- /dev/null +++ b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb @@ -0,0 +1,10 @@ +class AddIndexForLatestSuccessfulPipeline < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_concurrent_index(:ci_commits, [:gl_project_id, :ref, :status]) + end +end diff --git a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb new file mode 100644 index 00000000000..906711b9f3f --- /dev/null +++ b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb @@ -0,0 +1,8 @@ +class DropIndexForBuildsProjectStatus < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + + def change + remove_index(:ci_commits, [:gl_project_id, :status]) + end +end diff --git a/db/schema.rb b/db/schema.rb index e0208dab3d3..6be017e66b3 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: 20170215200045) do +ActiveRecord::Schema.define(version: 20170216141440) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -251,8 +251,8 @@ ActiveRecord::Schema.define(version: 20170215200045) do t.integer "lock_version" end + add_index "ci_commits", ["gl_project_id", "ref", "status"], name: "index_ci_commits_on_gl_project_id_and_ref_and_status", using: :btree add_index "ci_commits", ["gl_project_id", "sha"], name: "index_ci_commits_on_gl_project_id_and_sha", using: :btree - add_index "ci_commits", ["gl_project_id", "status"], name: "index_ci_commits_on_gl_project_id_and_status", using: :btree add_index "ci_commits", ["gl_project_id"], name: "index_ci_commits_on_gl_project_id", using: :btree add_index "ci_commits", ["status"], name: "index_ci_commits_on_status", using: :btree add_index "ci_commits", ["user_id"], name: "index_ci_commits_on_user_id", using: :btree -- cgit v1.2.3 From 479cdc2cac78241109d2cb9d8cfd22d36319d367 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Mon, 20 Feb 2017 14:50:32 +0100 Subject: Fix bad merge [ci skip] --- db/migrate/20170120131253_create_chat_teams.rb | 4 ++-- db/schema.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'db') diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb index 8f76b43960b..6476c239152 100644 --- a/db/migrate/20170120131253_create_chat_teams.rb +++ b/db/migrate/20170120131253_create_chat_teams.rb @@ -5,13 +5,13 @@ class CreateChatTeams < ActiveRecord::Migration def change create_table :chat_teams do |t| - t.integer :group_id, index: true + t.integer :namespace_id, index: true t.string :team_id t.string :name t.timestamps null: false end - add_foreign_key :chat_teams, :groups, on_delete: :cascade + add_foreign_key :chat_teams, :namespaces, on_delete: :cascade end end diff --git a/db/schema.rb b/db/schema.rb index 66863942b77..cb97e6d8a93 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,6 +61,7 @@ ActiveRecord::Schema.define(version: 20170215200045) 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 @@ -109,7 +110,6 @@ ActiveRecord::Schema.define(version: 20170215200045) 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 end @@ -590,9 +590,9 @@ ActiveRecord::Schema.define(version: 20170215200045) do end add_index "labels", ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true, using: :btree - add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree add_index "labels", ["title"], name: "index_labels_on_title", using: :btree + add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree create_table "lfs_objects", force: :cascade do |t| t.string "oid", null: false @@ -765,8 +765,8 @@ ActiveRecord::Schema.define(version: 20170215200045) 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" end @@ -1285,8 +1285,8 @@ ActiveRecord::Schema.define(version: 20170215200045) do t.datetime "otp_grace_period_started_at" t.boolean "ldap_email", default: false, null: false t.boolean "external", default: false - t.string "organization" t.string "incoming_email_token" + t.string "organization" t.boolean "authorized_projects_populated" t.boolean "notified_of_own_activity", default: false, null: false end -- cgit v1.2.3 From b7d8df503cf35b3048b273dc0cadb5ec39aac5e1 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Feb 2017 17:32:18 -0600 Subject: Enable Style/MutableConstant --- ...ve_from_developers_can_merge_to_protected_branches_merge_access.rb | 2 +- ...move_from_developers_can_push_to_protected_branches_push_access.rb | 2 +- db/migrate/20160729173930_remove_project_id_from_spam_logs.rb | 2 +- db/migrate/20160823081327_change_merge_error_to_text.rb | 2 +- db/migrate/20160824124900_add_table_issue_metrics.rb | 2 +- db/migrate/20160825052008_add_table_merge_request_metrics.rb | 2 +- db/migrate/20160829114652_add_markdown_cache_columns.rb | 2 +- db/migrate/20160831214543_migrate_project_features.rb | 2 +- db/migrate/20160831223750_remove_features_enabled_from_projects.rb | 2 +- db/migrate/20160913162434_remove_projects_pushes_since_gc.rb | 2 +- db/migrate/20160913212128_change_artifacts_size_column.rb | 2 +- db/migrate/20160915042921_create_merge_requests_closing_issues.rb | 2 +- db/migrate/20160919144305_add_type_to_labels.rb | 2 +- db/migrate/20161014173530_create_label_priorities.rb | 2 +- db/migrate/20161017125927_add_unique_index_to_labels.rb | 2 +- db/migrate/20161018024215_migrate_labels_priority.rb | 2 +- db/migrate/20161018024550_remove_priority_from_labels.rb | 2 +- db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb | 4 ++-- db/migrate/20161019213545_generate_project_feature_for_projects.rb | 2 +- db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb | 2 +- db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb | 4 ++-- db/migrate/20161025231710_migrate_jira_to_gem.rb | 2 +- db/migrate/20161031174110_migrate_subscriptions_project_id.rb | 2 +- db/migrate/20161031181638_add_unique_index_to_subscriptions.rb | 2 +- db/migrate/20161103171205_rename_repository_storage_column.rb | 2 +- db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb | 2 +- db/migrate/20161130095245_fill_routes_table.rb | 2 +- db/migrate/20161130101252_fill_projects_routes_table.rb | 2 +- db/migrate/20161201160452_migrate_project_statistics.rb | 2 +- db/migrate/20161207231620_fixup_environment_name_uniqueness.rb | 2 +- db/migrate/20161207231621_create_environment_name_unique_index.rb | 2 +- db/migrate/20161207231626_add_environment_slug.rb | 2 +- db/migrate/20161209153400_add_unique_index_for_environment_slug.rb | 2 +- db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb | 2 +- .../20161011222551_remove_inactive_jira_service_properties.rb | 2 +- db/post_migrate/20161221153951_rename_reserved_project_names.rb | 2 +- 36 files changed, 38 insertions(+), 38 deletions(-) (limited to 'db') diff --git a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb b/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb index 1db0df92bec..cd5d4286b31 100644 --- a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb +++ b/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb @@ -3,7 +3,7 @@ class MoveFromDevelopersCanMergeToProtectedBranchesMergeAccess < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC + DOWNTIME_REASON = <<-HEREDOC.freeze We're creating a `merge_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this is running, we might be left with a `protected_branch` _without_ an associated `merge_access_level`. The `protected_branches` table must not change while this is running, so downtime is required. diff --git a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb index 5c3e189bb5b..45e3368fa9b 100644 --- a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb +++ b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb @@ -3,7 +3,7 @@ class MoveFromDevelopersCanPushToProtectedBranchesPushAccess < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC + DOWNTIME_REASON = <<-HEREDOC.freeze We're creating a `push_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this is running, we might be left with a `protected_branch` _without_ an associated `push_access_level`. The `protected_branches` table must not change while this is running, so downtime is required. diff --git a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb index e28ab31d629..9995191ed9b 100644 --- a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb +++ b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb @@ -10,7 +10,7 @@ class RemoveProjectIdFromSpamLogs < ActiveRecord::Migration # 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 = 'Removing a column that contains data that is not used anywhere.' + DOWNTIME_REASON = 'Removing a column that contains data that is not used anywhere.'.freeze # 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 diff --git a/db/migrate/20160823081327_change_merge_error_to_text.rb b/db/migrate/20160823081327_change_merge_error_to_text.rb index 7920389cd83..6dbf8a8d5e5 100644 --- a/db/migrate/20160823081327_change_merge_error_to_text.rb +++ b/db/migrate/20160823081327_change_merge_error_to_text.rb @@ -2,7 +2,7 @@ class ChangeMergeErrorToText < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.' + DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.'.freeze def change change_column :merge_requests, :merge_error, :text, limit: 65535 diff --git a/db/migrate/20160824124900_add_table_issue_metrics.rb b/db/migrate/20160824124900_add_table_issue_metrics.rb index e9bb79b3c62..9e52c54a35b 100644 --- a/db/migrate/20160824124900_add_table_issue_metrics.rb +++ b/db/migrate/20160824124900_add_table_issue_metrics.rb @@ -10,7 +10,7 @@ class AddTableIssueMetrics < ActiveRecord::Migration # 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 = 'Adding foreign key' + DOWNTIME_REASON = 'Adding foreign key'.freeze # 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 diff --git a/db/migrate/20160825052008_add_table_merge_request_metrics.rb b/db/migrate/20160825052008_add_table_merge_request_metrics.rb index e01cc5038b9..195baf5f45b 100644 --- a/db/migrate/20160825052008_add_table_merge_request_metrics.rb +++ b/db/migrate/20160825052008_add_table_merge_request_metrics.rb @@ -10,7 +10,7 @@ class AddTableMergeRequestMetrics < ActiveRecord::Migration # 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 = 'Adding foreign key' + DOWNTIME_REASON = 'Adding foreign key'.freeze # 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 diff --git a/db/migrate/20160829114652_add_markdown_cache_columns.rb b/db/migrate/20160829114652_add_markdown_cache_columns.rb index 8753e55e058..9cb44dfa9f9 100644 --- a/db/migrate/20160829114652_add_markdown_cache_columns.rb +++ b/db/migrate/20160829114652_add_markdown_cache_columns.rb @@ -26,7 +26,7 @@ class AddMarkdownCacheColumns < ActiveRecord::Migration projects: [:description], releases: [:description], snippets: [:title, :content], - } + }.freeze def change COLUMNS.each do |table, columns| diff --git a/db/migrate/20160831214543_migrate_project_features.rb b/db/migrate/20160831214543_migrate_project_features.rb index 93f9821bc76..79a5fb29d64 100644 --- a/db/migrate/20160831214543_migrate_project_features.rb +++ b/db/migrate/20160831214543_migrate_project_features.rb @@ -3,7 +3,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration DOWNTIME = true DOWNTIME_REASON = - <<-EOT + <<-EOT.freeze Migrating issues_enabled, merge_requests_enabled, wiki_enabled, builds_enabled, snippets_enabled fields from projects to a new table called project_features. EOT diff --git a/db/migrate/20160831223750_remove_features_enabled_from_projects.rb b/db/migrate/20160831223750_remove_features_enabled_from_projects.rb index a2c207b49ea..8202c6a7b79 100644 --- a/db/migrate/20160831223750_remove_features_enabled_from_projects.rb +++ b/db/migrate/20160831223750_remove_features_enabled_from_projects.rb @@ -7,7 +7,7 @@ class RemoveFeaturesEnabledFromProjects < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = true - DOWNTIME_REASON = "Removing fields from database requires downtine." + DOWNTIME_REASON = "Removing fields from database requires downtine.".freeze def up remove_column :projects, :issues_enabled diff --git a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb index 18ea9d43a43..919bfcdd86e 100644 --- a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb +++ b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb @@ -5,7 +5,7 @@ class RemoveProjectsPushesSinceGc < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column' + DOWNTIME_REASON = 'This migration removes an existing column'.freeze disable_ddl_transaction! diff --git a/db/migrate/20160913212128_change_artifacts_size_column.rb b/db/migrate/20160913212128_change_artifacts_size_column.rb index 063bbca537c..8cda4b66c5a 100644 --- a/db/migrate/20160913212128_change_artifacts_size_column.rb +++ b/db/migrate/20160913212128_change_artifacts_size_column.rb @@ -3,7 +3,7 @@ class ChangeArtifactsSizeColumn < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = 'Changing an integer column size requires a full table rewrite.' + DOWNTIME_REASON = 'Changing an integer column size requires a full table rewrite.'.freeze def up change_column :ci_builds, :artifacts_size, :integer, limit: 8 diff --git a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb index 94874a853da..105278d49f7 100644 --- a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb +++ b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb @@ -10,7 +10,7 @@ class CreateMergeRequestsClosingIssues < ActiveRecord::Migration # 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 = 'Adding foreign keys' + DOWNTIME_REASON = 'Adding foreign keys'.freeze # 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 diff --git a/db/migrate/20160919144305_add_type_to_labels.rb b/db/migrate/20160919144305_add_type_to_labels.rb index 66172bda6ff..f028c9460d1 100644 --- a/db/migrate/20160919144305_add_type_to_labels.rb +++ b/db/migrate/20160919144305_add_type_to_labels.rb @@ -2,7 +2,7 @@ class AddTypeToLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.' + DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.'.freeze def change add_column :labels, :type, :string diff --git a/db/migrate/20161014173530_create_label_priorities.rb b/db/migrate/20161014173530_create_label_priorities.rb index 2c22841c28a..73c9897631c 100644 --- a/db/migrate/20161014173530_create_label_priorities.rb +++ b/db/migrate/20161014173530_create_label_priorities.rb @@ -2,7 +2,7 @@ class CreateLabelPriorities < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration adds foreign keys' + DOWNTIME_REASON = 'This migration adds foreign keys'.freeze disable_ddl_transaction! diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb index f2b56ebfb7b..5571160ccb4 100644 --- a/db/migrate/20161017125927_add_unique_index_to_labels.rb +++ b/db/migrate/20161017125927_add_unique_index_to_labels.rb @@ -2,7 +2,7 @@ class AddUniqueIndexToLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes duplicated labels.' + DOWNTIME_REASON = 'This migration removes duplicated labels.'.freeze disable_ddl_transaction! diff --git a/db/migrate/20161018024215_migrate_labels_priority.rb b/db/migrate/20161018024215_migrate_labels_priority.rb index 22bec2382f4..9529bd3d494 100644 --- a/db/migrate/20161018024215_migrate_labels_priority.rb +++ b/db/migrate/20161018024215_migrate_labels_priority.rb @@ -2,7 +2,7 @@ class MigrateLabelsPriority < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Prioritized labels will not work as expected until this migration is complete.' + DOWNTIME_REASON = 'Prioritized labels will not work as expected until this migration is complete.'.freeze disable_ddl_transaction! diff --git a/db/migrate/20161018024550_remove_priority_from_labels.rb b/db/migrate/20161018024550_remove_priority_from_labels.rb index b7416cca664..4415a2e91af 100644 --- a/db/migrate/20161018024550_remove_priority_from_labels.rb +++ b/db/migrate/20161018024550_remove_priority_from_labels.rb @@ -2,7 +2,7 @@ class RemovePriorityFromLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column' + DOWNTIME_REASON = 'This migration removes an existing column'.freeze disable_ddl_transaction! diff --git a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb index e875213ab96..9730ebb8f8a 100644 --- a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb +++ b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb @@ -8,7 +8,7 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-EOF + DOWNTIME_REASON = <<-EOF.freeze Moving Sidekiq jobs from queues requires Sidekiq to be stopped. Not stopping Sidekiq will result in the loss of jobs that are scheduled after this migration completes. @@ -71,7 +71,7 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration 'StuckCiBuildsWorker' => :cronjob, 'UpdateMergeRequestsWorker' => :update_merge_requests } - } + }.freeze def up Sidekiq.redis do |redis| diff --git a/db/migrate/20161019213545_generate_project_feature_for_projects.rb b/db/migrate/20161019213545_generate_project_feature_for_projects.rb index 4554e14b0df..6486181575d 100644 --- a/db/migrate/20161019213545_generate_project_feature_for_projects.rb +++ b/db/migrate/20161019213545_generate_project_feature_for_projects.rb @@ -1,7 +1,7 @@ class GenerateProjectFeatureForProjects < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC + DOWNTIME_REASON = <<-HEREDOC.freeze Application was eager loading project_feature for all projects generating an extra query everytime a project was fetched. We removed that behavior to avoid the extra query, this migration makes sure all projects have a project_feature record associated. diff --git a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb index 2abfe47b776..b396c03ecbf 100644 --- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb +++ b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb @@ -12,7 +12,7 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration # 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 = 'Adding a foreign key' + DOWNTIME_REASON = 'Adding a foreign key'.freeze # 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 diff --git a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb index 06d07bdb835..4167ccae39b 100644 --- a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb +++ b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb @@ -8,7 +8,7 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-EOF + DOWNTIME_REASON = <<-EOF.freeze Moving Sidekiq jobs from queues requires Sidekiq to be stopped. Not stopping Sidekiq will result in the loss of jobs that are scheduled after this migration completes. @@ -25,7 +25,7 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration incoming_email: { 'EmailReceiverWorker' => :email_receiver } - } + }.freeze def up Sidekiq.redis do |redis| diff --git a/db/migrate/20161025231710_migrate_jira_to_gem.rb b/db/migrate/20161025231710_migrate_jira_to_gem.rb index 870b00411d2..38824ba9fe5 100644 --- a/db/migrate/20161025231710_migrate_jira_to_gem.rb +++ b/db/migrate/20161025231710_migrate_jira_to_gem.rb @@ -1,7 +1,7 @@ class MigrateJiraToGem < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC + DOWNTIME_REASON = <<-HEREDOC.freeze Refactor all Jira services properties(serialized field) to use new jira-ruby gem. There were properties on old Jira service that are not needed anymore after the service refactoring: api_url, project_url, new_issue_url, issues_url. diff --git a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb index 549145a0a65..130b5f556ff 100644 --- a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb +++ b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb @@ -2,7 +2,7 @@ class MigrateSubscriptionsProjectId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Subscriptions will not work as expected until this migration is complete.' + DOWNTIME_REASON = 'Subscriptions will not work as expected until this migration is complete.'.freeze def up execute <<-EOF.strip_heredoc diff --git a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb index 4b1b29e1265..1b675a36db7 100644 --- a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb +++ b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb @@ -2,7 +2,7 @@ class AddUniqueIndexToSubscriptions < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it changes a column to not accept null values.' + DOWNTIME_REASON = 'This migration requires downtime because it changes a column to not accept null values.'.freeze disable_ddl_transaction! diff --git a/db/migrate/20161103171205_rename_repository_storage_column.rb b/db/migrate/20161103171205_rename_repository_storage_column.rb index 93280573939..32d22e630d8 100644 --- a/db/migrate/20161103171205_rename_repository_storage_column.rb +++ b/db/migrate/20161103171205_rename_repository_storage_column.rb @@ -10,7 +10,7 @@ class RenameRepositoryStorageColumn < ActiveRecord::Migration # 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 = 'Renaming the application_settings.repository_storage column' + DOWNTIME_REASON = 'Renaming the application_settings.repository_storage column'.freeze # 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 diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 77e0c40d850..633f57ef600 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -25,7 +25,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration end DOWNTIME = true - DOWNTIME_REASON = 'Existing workers will error until they are using a newer version of the code' + DOWNTIME_REASON = 'Existing workers will error until they are using a newer version of the code'.freeze disable_ddl_transaction! diff --git a/db/migrate/20161130095245_fill_routes_table.rb b/db/migrate/20161130095245_fill_routes_table.rb index c3536d6d911..ccd2cceee0c 100644 --- a/db/migrate/20161130095245_fill_routes_table.rb +++ b/db/migrate/20161130095245_fill_routes_table.rb @@ -5,7 +5,7 @@ class FillRoutesTable < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'No new namespaces should be created during data copy' + DOWNTIME_REASON = 'No new namespaces should be created during data copy'.freeze def up execute <<-EOF diff --git a/db/migrate/20161130101252_fill_projects_routes_table.rb b/db/migrate/20161130101252_fill_projects_routes_table.rb index 56ba6fcdbe3..5e7d0e75ad8 100644 --- a/db/migrate/20161130101252_fill_projects_routes_table.rb +++ b/db/migrate/20161130101252_fill_projects_routes_table.rb @@ -5,7 +5,7 @@ class FillProjectsRoutesTable < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'No new projects should be created during data copy' + DOWNTIME_REASON = 'No new projects should be created during data copy'.freeze def up if Gitlab::Database.postgresql? diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb index 3ae3f2c159b..afd5ce95068 100644 --- a/db/migrate/20161201160452_migrate_project_statistics.rb +++ b/db/migrate/20161201160452_migrate_project_statistics.rb @@ -2,7 +2,7 @@ class MigrateProjectStatistics < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Removes two columns from the projects table' + DOWNTIME_REASON = 'Removes two columns from the projects table'.freeze def up # convert repository_size in float (megabytes) to integer (bytes), diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index b74552e762d..57f28e809de 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -2,7 +2,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Renaming non-unique environments' + DOWNTIME_REASON = 'Renaming non-unique environments'.freeze def up environments = Arel::Table.new(:environments) diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb index ac680c8d10f..94fa3b6838c 100644 --- a/db/migrate/20161207231621_create_environment_name_unique_index.rb +++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb @@ -4,7 +4,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration disable_ddl_transaction! DOWNTIME = true - DOWNTIME_REASON = 'Making a non-unique index into a unique index' + DOWNTIME_REASON = 'Making a non-unique index into a unique index'.freeze def up remove_index :environments, [:project_id, :name] diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 8e98ee5b9ba..aec08dc79f2 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -5,7 +5,7 @@ class AddEnvironmentSlug < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data' + DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data'.freeze # Used to generate random suffixes for the slug LETTERS = 'a'..'z' diff --git a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb index e9fcef1cd45..fbf6e4c2a45 100644 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb @@ -5,7 +5,7 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Adding a *unique* index to environments.slug' + DOWNTIME_REASON = 'Adding a *unique* index to environments.slug'.freeze disable_ddl_transaction! diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb index 69bfa2d3fc4..2b2b7ab27ce 100644 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb @@ -9,7 +9,7 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration # 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 = '' + DOWNTIME_REASON = ''.freeze # 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 diff --git a/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb index 319d86ac159..eacc6d1b033 100644 --- a/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb +++ b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb @@ -2,7 +2,7 @@ class RemoveInactiveJiraServiceProperties < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = "Removes all inactive jira_service properties" + DOWNTIME_REASON = "Removes all inactive jira_service properties".freeze def up execute("UPDATE services SET properties = '{}' WHERE services.type = 'JiraService' and services.active = false") diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index 282837be1fa..49a6bc884a8 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -37,7 +37,7 @@ class RenameReservedProjectNames < ActiveRecord::Migration unsubscribes update users - wikis) + wikis).freeze def up queues = Array.new(THREAD_COUNT) { Queue.new } -- cgit v1.2.3 From d78513cb6ccfe10976cc433e2b421c30d06d19be Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Feb 2017 18:42:22 -0600 Subject: Enable Security/JSONLoad --- db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb | 2 +- db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb | 2 +- db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb index 9730ebb8f8a..3a7acc84028 100644 --- a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb +++ b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb @@ -93,7 +93,7 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration def migrate_from_queue(redis, queue, job_mapping) while job = redis.lpop("queue:#{queue}") - payload = JSON.load(job) + payload = JSON.parse(job) new_queue = job_mapping[payload['class']] # If we have no target queue to migrate to we're probably dealing with diff --git a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb index 4167ccae39b..91d078f6293 100644 --- a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb +++ b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb @@ -47,7 +47,7 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration def migrate_from_queue(redis, queue, job_mapping) while job = redis.lpop("queue:#{queue}") - payload = JSON.load(job) + payload = JSON.parse(job) new_queue = job_mapping[payload['class']] # If we have no target queue to migrate to we're probably dealing with diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 633f57ef600..35697aab207 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -34,7 +34,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration new_jobs = [] while job = redis.lpop('queue:process_commit') - payload = JSON.load(job) + payload = JSON.parse(job) project = Project.find_including_path(payload['args'][0]) next unless project @@ -75,7 +75,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration new_jobs = [] while job = redis.lpop('queue:process_commit') - payload = JSON.load(job) + payload = JSON.parse(job) payload['args'][2] = payload['args'][2]['id'] -- cgit v1.2.3 From baafd8de26507ebd76177b5c65b5da921445ddc9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Feb 2017 18:47:39 -0600 Subject: Enable Style/BarePercentLiterals --- db/migrate/20160610201627_migrate_users_notification_level.rb | 4 ++-- db/migrate/20160831214543_migrate_project_features.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb index 760b766828e..798e315102e 100644 --- a/db/migrate/20160610201627_migrate_users_notification_level.rb +++ b/db/migrate/20160610201627_migrate_users_notification_level.rb @@ -3,7 +3,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration # creating a new record on notification settings table def up - execute(%Q{ + execute(%{ INSERT INTO notification_settings (user_id, level, created_at, updated_at) (SELECT id, notification_level, created_at, updated_at FROM users WHERE notification_level != 1) @@ -13,7 +13,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration # Migrates from notification settings back to user notification_level # If no value is found the default level of 1 will be used def down - execute(%Q{ + execute(%{ UPDATE users u SET notification_level = COALESCE((SELECT level FROM notification_settings WHERE user_id = u.id AND source_type IS NULL), 1) }) diff --git a/db/migrate/20160831214543_migrate_project_features.rb b/db/migrate/20160831214543_migrate_project_features.rb index 79a5fb29d64..a2f2267773c 100644 --- a/db/migrate/20160831214543_migrate_project_features.rb +++ b/db/migrate/20160831214543_migrate_project_features.rb @@ -10,7 +10,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration def up sql = - %Q{ + %{ INSERT INTO project_features(project_id, issues_access_level, merge_requests_access_level, wiki_access_level, builds_access_level, snippets_access_level, created_at, updated_at) SELECT @@ -29,7 +29,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration end def down - sql = %Q{ + sql = %{ UPDATE projects SET issues_enabled = COALESCE((SELECT CASE WHEN issues_access_level = 20 THEN true ELSE false END AS issues_enabled FROM project_features WHERE project_features.project_id = projects.id), true), -- cgit v1.2.3 From 0b27d63359cdc6968cbb48b56bd168bddc09950e Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 22 Feb 2017 09:13:02 -0600 Subject: =?UTF-8?q?Old=20migration=20doesn=E2=80=99t=20require=20downtime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20160610201627_migrate_users_notification_level.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'db') diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb index 798e315102e..9da67b59dd1 100644 --- a/db/migrate/20160610201627_migrate_users_notification_level.rb +++ b/db/migrate/20160610201627_migrate_users_notification_level.rb @@ -2,6 +2,8 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration # Migrates only users who changed their default notification level :participating # creating a new record on notification settings table + DOWNTIME = false + def up execute(%{ INSERT INTO notification_settings -- cgit v1.2.3 From 206953a430e442fbbd06984b1120890dbf8d3f79 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 22 Feb 2017 10:55:08 -0600 Subject: Prefer leading style for Style/DotPosition --- ...124141322_migrate_process_commit_worker_jobs.rb | 6 ++-- ...1207231620_fixup_environment_name_uniqueness.rb | 32 +++++++++++----------- db/migrate/20161207231626_add_environment_slug.rb | 8 +++--- ..._fix_project_records_with_invalid_visibility.rb | 22 +++++++-------- ...20161221153951_rename_reserved_project_names.rb | 12 ++++---- ...170104150317_requeue_pending_delete_projects.rb | 12 ++++---- .../20170106142508_fill_authorized_projects.rb | 4 +-- 7 files changed, 48 insertions(+), 48 deletions(-) (limited to 'db') diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 35697aab207..3865f3e3a08 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -6,9 +6,9 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration class Project < ActiveRecord::Base def self.find_including_path(id) - select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace"). - joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id'). - find_by(id: id) + select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace") + .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id') + .find_by(id: id) end def repository_storage_path diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index 57f28e809de..b31f9699f3d 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -8,11 +8,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration environments = Arel::Table.new(:environments) # Get all [project_id, name] pairs that occur more than once - finder_sql = environments. - group(environments[:project_id], environments[:name]). - having(Arel.sql("COUNT(1)").gt(1)). - project(environments[:project_id], environments[:name]). - to_sql + finder_sql = environments + .group(environments[:project_id], environments[:name]) + .having(Arel.sql("COUNT(1)").gt(1)) + .project(environments[:project_id], environments[:name]) + .to_sql conflicting = connection.exec_query(finder_sql) @@ -28,12 +28,12 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration # Rename conflicting environments by appending "-#{id}" to all but the first def fix_duplicates(project_id, name) environments = Arel::Table.new(:environments) - finder_sql = environments. - where(environments[:project_id].eq(project_id)). - where(environments[:name].eq(name)). - order(environments[:id].asc). - project(environments[:id], environments[:name]). - to_sql + finder_sql = environments + .where(environments[:project_id].eq(project_id)) + .where(environments[:name].eq(name)) + .order(environments[:id].asc) + .project(environments[:id], environments[:name]) + .to_sql # Now we have the data for all the conflicting rows conflicts = connection.exec_query(finder_sql).rows @@ -41,11 +41,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration conflicts.each do |id, name| update_sql = - Arel::UpdateManager.new(ActiveRecord::Base). - table(environments). - set(environments[:name] => name + "-" + id.to_s). - where(environments[:id].eq(id)). - to_sql + Arel::UpdateManager.new(ActiveRecord::Base) + .table(environments) + .set(environments[:name] => name + "-" + id.to_s) + .where(environments[:id].eq(id)) + .to_sql connection.exec_update(update_sql, self.class.name, []) end diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index aec08dc79f2..1dec96a1299 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -19,10 +19,10 @@ class AddEnvironmentSlug < ActiveRecord::Migration finder = environments.project(:id, :name) connection.exec_query(finder.to_sql).rows.each do |id, name| - updater = Arel::UpdateManager.new(ActiveRecord::Base). - table(environments). - set(environments[:slug] => generate_slug(name)). - where(environments[:id].eq(id)) + updater = Arel::UpdateManager.new(ActiveRecord::Base) + .table(environments) + .set(environments[:slug] => generate_slug(name)) + .where(environments[:id].eq(id)) connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb index df38591a333..823274b08c0 100644 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -13,13 +13,13 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration namespaces = Arel::Table.new(:namespaces) finder_sql = - projects. - join(namespaces, Arel::Nodes::InnerJoin). - on(projects[:namespace_id].eq(namespaces[:id])). - where(projects[:visibility_level].gt(namespaces[:visibility_level])). - project(projects[:id], namespaces[:visibility_level]). - take(BATCH_SIZE). - to_sql + projects + .join(namespaces, Arel::Nodes::InnerJoin) + .on(projects[:namespace_id].eq(namespaces[:id])) + .where(projects[:visibility_level].gt(namespaces[:visibility_level])) + .project(projects[:id], namespaces[:visibility_level]) + .take(BATCH_SIZE) + .to_sql # Update matching rows in batches. Each batch can cause up to 3 UPDATE # statements, in addition to the SELECT: one per visibility_level @@ -33,10 +33,10 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration end updates.each do |visibility_level, project_ids| - updater = Arel::UpdateManager.new(ActiveRecord::Base). - table(projects). - set(projects[:visibility_level] => visibility_level). - where(projects[:id].in(project_ids)) + updater = Arel::UpdateManager.new(ActiveRecord::Base) + .table(projects) + .set(projects[:visibility_level] => visibility_level) + .where(projects[:id].in(project_ids)) ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index 49a6bc884a8..d322844e2fd 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -79,17 +79,17 @@ class RenameReservedProjectNames < ActiveRecord::Migration 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) + 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) - ActiveRecord::Base.connection. - select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? + ActiveRecord::Base.connection + .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? end # Adds number to the end of the path that is not taken by other route diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb index f399950bd5e..d7be004d47f 100644 --- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb +++ b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb @@ -39,11 +39,11 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration def find_batch projects = Arel::Table.new(:projects) - projects.project(projects[:id]). - where(projects[:pending_delete].eq(true)). - where(projects[:namespace_id].not_eq(nil)). - skip(@offset * BATCH_SIZE). - take(BATCH_SIZE). - to_sql + projects.project(projects[:id]) + .where(projects[:pending_delete].eq(true)) + .where(projects[:namespace_id].not_eq(nil)) + .skip(@offset * BATCH_SIZE) + .take(BATCH_SIZE) + .to_sql end end diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb index 314c8440c8b..0ca20587981 100644 --- a/db/post_migrate/20170106142508_fill_authorized_projects.rb +++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb @@ -15,8 +15,8 @@ class FillAuthorizedProjects < ActiveRecord::Migration disable_ddl_transaction! def up - relation = User.select(:id). - where('authorized_projects_populated IS NOT TRUE') + relation = User.select(:id) + .where('authorized_projects_populated IS NOT TRUE') relation.find_in_batches(batch_size: 1_000) do |rows| args = rows.map { |row| [row.id] } -- cgit v1.2.3 From 7d4b52b27dcbe30d85d4fad27e983cee51cf6677 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 22 Feb 2017 11:46:57 -0600 Subject: Enable Style/WordArray --- db/migrate/20161128142110_remove_unnecessary_indexes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20161128142110_remove_unnecessary_indexes.rb b/db/migrate/20161128142110_remove_unnecessary_indexes.rb index 9deab19782e..8100287ef48 100644 --- a/db/migrate/20161128142110_remove_unnecessary_indexes.rb +++ b/db/migrate/20161128142110_remove_unnecessary_indexes.rb @@ -12,7 +12,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id) remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id) remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id) - remove_index :deployments, column: ["project_id", "environment_id"] if index_exists?(:deployments, ["project_id", "environment_id"]) + remove_index :deployments, column: %w(project_id environment_id) if index_exists?(:deployments, %w(project_id environment_id)) remove_index :lists, column: :board_id if index_exists?(:lists, :board_id) remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id) remove_index :notes, column: :project_id if index_exists?(:notes, :project_id) @@ -24,7 +24,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration add_concurrent_index :award_emoji, :user_id add_concurrent_index :ci_builds, :commit_id add_concurrent_index :deployments, :project_id - add_concurrent_index :deployments, ["project_id", "environment_id"] + add_concurrent_index :deployments, %w(project_id environment_id) add_concurrent_index :lists, :board_id add_concurrent_index :milestones, :project_id add_concurrent_index :notes, :project_id -- cgit v1.2.3 From 0a5b670a9392f7f8c02e83f1c2e3ed4d2d67cfde Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 22 Feb 2017 16:34:45 -0600 Subject: Exclude migrations from Style/MutableConstant --- ...elopers_can_merge_to_protected_branches_merge_access.rb | 2 +- ...evelopers_can_push_to_protected_branches_push_access.rb | 2 +- .../20160729173930_remove_project_id_from_spam_logs.rb | 2 +- db/migrate/20160823081327_change_merge_error_to_text.rb | 2 +- db/migrate/20160824124900_add_table_issue_metrics.rb | 2 +- .../20160825052008_add_table_merge_request_metrics.rb | 2 +- ...20160831223750_remove_features_enabled_from_projects.rb | 2 +- .../20160913162434_remove_projects_pushes_since_gc.rb | 2 +- db/migrate/20160913212128_change_artifacts_size_column.rb | 2 +- .../20160915042921_create_merge_requests_closing_issues.rb | 2 +- db/migrate/20160919144305_add_type_to_labels.rb | 2 +- db/migrate/20161014173530_create_label_priorities.rb | 2 +- db/migrate/20161017125927_add_unique_index_to_labels.rb | 2 +- db/migrate/20161018024215_migrate_labels_priority.rb | 2 +- db/migrate/20161018024550_remove_priority_from_labels.rb | 2 +- .../20161019190736_migrate_sidekiq_queues_from_default.rb | 2 +- ...20161019213545_generate_project_feature_for_projects.rb | 2 +- ...61020083353_add_pipeline_id_to_merge_request_metrics.rb | 2 +- .../20161024042317_migrate_mailroom_queue_from_default.rb | 2 +- db/migrate/20161025231710_migrate_jira_to_gem.rb | 2 +- .../20161031174110_migrate_subscriptions_project_id.rb | 2 +- .../20161031181638_add_unique_index_to_subscriptions.rb | 2 +- .../20161103171205_rename_repository_storage_column.rb | 2 +- .../20161124141322_migrate_process_commit_worker_jobs.rb | 2 +- db/migrate/20161130095245_fill_routes_table.rb | 2 +- db/migrate/20161130101252_fill_projects_routes_table.rb | 2 +- db/migrate/20161201160452_migrate_project_statistics.rb | 2 +- .../20161207231620_fixup_environment_name_uniqueness.rb | 10 +++++----- .../20161207231621_create_environment_name_unique_index.rb | 2 +- db/migrate/20161207231626_add_environment_slug.rb | 2 +- ...20161209153400_add_unique_index_for_environment_slug.rb | 2 +- db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb | 2 +- ...161011222551_remove_inactive_jira_service_properties.rb | 2 +- ...09150329_fix_project_records_with_invalid_visibility.rb | 14 +++++++------- 34 files changed, 44 insertions(+), 44 deletions(-) (limited to 'db') diff --git a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb b/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb index cd5d4286b31..1db0df92bec 100644 --- a/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb +++ b/db/migrate/20160705055254_move_from_developers_can_merge_to_protected_branches_merge_access.rb @@ -3,7 +3,7 @@ class MoveFromDevelopersCanMergeToProtectedBranchesMergeAccess < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC.freeze + DOWNTIME_REASON = <<-HEREDOC We're creating a `merge_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this is running, we might be left with a `protected_branch` _without_ an associated `merge_access_level`. The `protected_branches` table must not change while this is running, so downtime is required. diff --git a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb index 45e3368fa9b..5c3e189bb5b 100644 --- a/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb +++ b/db/migrate/20160705055308_move_from_developers_can_push_to_protected_branches_push_access.rb @@ -3,7 +3,7 @@ class MoveFromDevelopersCanPushToProtectedBranchesPushAccess < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC.freeze + DOWNTIME_REASON = <<-HEREDOC We're creating a `push_access_level` for each `protected_branch`. If a user creates a `protected_branch` while this is running, we might be left with a `protected_branch` _without_ an associated `push_access_level`. The `protected_branches` table must not change while this is running, so downtime is required. diff --git a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb index 9995191ed9b..e28ab31d629 100644 --- a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb +++ b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb @@ -10,7 +10,7 @@ class RemoveProjectIdFromSpamLogs < ActiveRecord::Migration # 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 = 'Removing a column that contains data that is not used anywhere.'.freeze + DOWNTIME_REASON = 'Removing a column that contains data that is not used anywhere.' # 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 diff --git a/db/migrate/20160823081327_change_merge_error_to_text.rb b/db/migrate/20160823081327_change_merge_error_to_text.rb index 6dbf8a8d5e5..7920389cd83 100644 --- a/db/migrate/20160823081327_change_merge_error_to_text.rb +++ b/db/migrate/20160823081327_change_merge_error_to_text.rb @@ -2,7 +2,7 @@ class ChangeMergeErrorToText < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.'.freeze + DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.' def change change_column :merge_requests, :merge_error, :text, limit: 65535 diff --git a/db/migrate/20160824124900_add_table_issue_metrics.rb b/db/migrate/20160824124900_add_table_issue_metrics.rb index 9e52c54a35b..e9bb79b3c62 100644 --- a/db/migrate/20160824124900_add_table_issue_metrics.rb +++ b/db/migrate/20160824124900_add_table_issue_metrics.rb @@ -10,7 +10,7 @@ class AddTableIssueMetrics < ActiveRecord::Migration # 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 = 'Adding foreign key'.freeze + DOWNTIME_REASON = 'Adding foreign key' # 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 diff --git a/db/migrate/20160825052008_add_table_merge_request_metrics.rb b/db/migrate/20160825052008_add_table_merge_request_metrics.rb index 195baf5f45b..e01cc5038b9 100644 --- a/db/migrate/20160825052008_add_table_merge_request_metrics.rb +++ b/db/migrate/20160825052008_add_table_merge_request_metrics.rb @@ -10,7 +10,7 @@ class AddTableMergeRequestMetrics < ActiveRecord::Migration # 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 = 'Adding foreign key'.freeze + DOWNTIME_REASON = 'Adding foreign key' # 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 diff --git a/db/migrate/20160831223750_remove_features_enabled_from_projects.rb b/db/migrate/20160831223750_remove_features_enabled_from_projects.rb index 8202c6a7b79..a2c207b49ea 100644 --- a/db/migrate/20160831223750_remove_features_enabled_from_projects.rb +++ b/db/migrate/20160831223750_remove_features_enabled_from_projects.rb @@ -7,7 +7,7 @@ class RemoveFeaturesEnabledFromProjects < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = true - DOWNTIME_REASON = "Removing fields from database requires downtine.".freeze + DOWNTIME_REASON = "Removing fields from database requires downtine." def up remove_column :projects, :issues_enabled diff --git a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb index 919bfcdd86e..18ea9d43a43 100644 --- a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb +++ b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb @@ -5,7 +5,7 @@ class RemoveProjectsPushesSinceGc < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column'.freeze + DOWNTIME_REASON = 'This migration removes an existing column' disable_ddl_transaction! diff --git a/db/migrate/20160913212128_change_artifacts_size_column.rb b/db/migrate/20160913212128_change_artifacts_size_column.rb index 8cda4b66c5a..063bbca537c 100644 --- a/db/migrate/20160913212128_change_artifacts_size_column.rb +++ b/db/migrate/20160913212128_change_artifacts_size_column.rb @@ -3,7 +3,7 @@ class ChangeArtifactsSizeColumn < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = 'Changing an integer column size requires a full table rewrite.'.freeze + DOWNTIME_REASON = 'Changing an integer column size requires a full table rewrite.' def up change_column :ci_builds, :artifacts_size, :integer, limit: 8 diff --git a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb index 105278d49f7..94874a853da 100644 --- a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb +++ b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb @@ -10,7 +10,7 @@ class CreateMergeRequestsClosingIssues < ActiveRecord::Migration # 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 = 'Adding foreign keys'.freeze + DOWNTIME_REASON = 'Adding foreign keys' # 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 diff --git a/db/migrate/20160919144305_add_type_to_labels.rb b/db/migrate/20160919144305_add_type_to_labels.rb index f028c9460d1..66172bda6ff 100644 --- a/db/migrate/20160919144305_add_type_to_labels.rb +++ b/db/migrate/20160919144305_add_type_to_labels.rb @@ -2,7 +2,7 @@ class AddTypeToLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.'.freeze + DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.' def change add_column :labels, :type, :string diff --git a/db/migrate/20161014173530_create_label_priorities.rb b/db/migrate/20161014173530_create_label_priorities.rb index 73c9897631c..2c22841c28a 100644 --- a/db/migrate/20161014173530_create_label_priorities.rb +++ b/db/migrate/20161014173530_create_label_priorities.rb @@ -2,7 +2,7 @@ class CreateLabelPriorities < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration adds foreign keys'.freeze + DOWNTIME_REASON = 'This migration adds foreign keys' disable_ddl_transaction! diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb index 5571160ccb4..f2b56ebfb7b 100644 --- a/db/migrate/20161017125927_add_unique_index_to_labels.rb +++ b/db/migrate/20161017125927_add_unique_index_to_labels.rb @@ -2,7 +2,7 @@ class AddUniqueIndexToLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes duplicated labels.'.freeze + DOWNTIME_REASON = 'This migration removes duplicated labels.' disable_ddl_transaction! diff --git a/db/migrate/20161018024215_migrate_labels_priority.rb b/db/migrate/20161018024215_migrate_labels_priority.rb index 9529bd3d494..22bec2382f4 100644 --- a/db/migrate/20161018024215_migrate_labels_priority.rb +++ b/db/migrate/20161018024215_migrate_labels_priority.rb @@ -2,7 +2,7 @@ class MigrateLabelsPriority < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Prioritized labels will not work as expected until this migration is complete.'.freeze + DOWNTIME_REASON = 'Prioritized labels will not work as expected until this migration is complete.' disable_ddl_transaction! diff --git a/db/migrate/20161018024550_remove_priority_from_labels.rb b/db/migrate/20161018024550_remove_priority_from_labels.rb index 4415a2e91af..b7416cca664 100644 --- a/db/migrate/20161018024550_remove_priority_from_labels.rb +++ b/db/migrate/20161018024550_remove_priority_from_labels.rb @@ -2,7 +2,7 @@ class RemovePriorityFromLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration removes an existing column'.freeze + DOWNTIME_REASON = 'This migration removes an existing column' disable_ddl_transaction! diff --git a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb index 3a7acc84028..9f502a8df73 100644 --- a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb +++ b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb @@ -8,7 +8,7 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-EOF.freeze + DOWNTIME_REASON = <<-EOF Moving Sidekiq jobs from queues requires Sidekiq to be stopped. Not stopping Sidekiq will result in the loss of jobs that are scheduled after this migration completes. diff --git a/db/migrate/20161019213545_generate_project_feature_for_projects.rb b/db/migrate/20161019213545_generate_project_feature_for_projects.rb index 6486181575d..4554e14b0df 100644 --- a/db/migrate/20161019213545_generate_project_feature_for_projects.rb +++ b/db/migrate/20161019213545_generate_project_feature_for_projects.rb @@ -1,7 +1,7 @@ class GenerateProjectFeatureForProjects < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC.freeze + DOWNTIME_REASON = <<-HEREDOC Application was eager loading project_feature for all projects generating an extra query everytime a project was fetched. We removed that behavior to avoid the extra query, this migration makes sure all projects have a project_feature record associated. diff --git a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb index b396c03ecbf..2abfe47b776 100644 --- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb +++ b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb @@ -12,7 +12,7 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration # 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 = 'Adding a foreign key'.freeze + DOWNTIME_REASON = 'Adding a foreign key' # 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 diff --git a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb index 91d078f6293..fc2e4c12b30 100644 --- a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb +++ b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb @@ -8,7 +8,7 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-EOF.freeze + DOWNTIME_REASON = <<-EOF Moving Sidekiq jobs from queues requires Sidekiq to be stopped. Not stopping Sidekiq will result in the loss of jobs that are scheduled after this migration completes. diff --git a/db/migrate/20161025231710_migrate_jira_to_gem.rb b/db/migrate/20161025231710_migrate_jira_to_gem.rb index 38824ba9fe5..870b00411d2 100644 --- a/db/migrate/20161025231710_migrate_jira_to_gem.rb +++ b/db/migrate/20161025231710_migrate_jira_to_gem.rb @@ -1,7 +1,7 @@ class MigrateJiraToGem < ActiveRecord::Migration DOWNTIME = true - DOWNTIME_REASON = <<-HEREDOC.freeze + DOWNTIME_REASON = <<-HEREDOC Refactor all Jira services properties(serialized field) to use new jira-ruby gem. There were properties on old Jira service that are not needed anymore after the service refactoring: api_url, project_url, new_issue_url, issues_url. diff --git a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb index 130b5f556ff..549145a0a65 100644 --- a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb +++ b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb @@ -2,7 +2,7 @@ class MigrateSubscriptionsProjectId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Subscriptions will not work as expected until this migration is complete.'.freeze + DOWNTIME_REASON = 'Subscriptions will not work as expected until this migration is complete.' def up execute <<-EOF.strip_heredoc diff --git a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb index 1b675a36db7..4b1b29e1265 100644 --- a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb +++ b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb @@ -2,7 +2,7 @@ class AddUniqueIndexToSubscriptions < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'This migration requires downtime because it changes a column to not accept null values.'.freeze + DOWNTIME_REASON = 'This migration requires downtime because it changes a column to not accept null values.' disable_ddl_transaction! diff --git a/db/migrate/20161103171205_rename_repository_storage_column.rb b/db/migrate/20161103171205_rename_repository_storage_column.rb index 32d22e630d8..93280573939 100644 --- a/db/migrate/20161103171205_rename_repository_storage_column.rb +++ b/db/migrate/20161103171205_rename_repository_storage_column.rb @@ -10,7 +10,7 @@ class RenameRepositoryStorageColumn < ActiveRecord::Migration # 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 = 'Renaming the application_settings.repository_storage column'.freeze + DOWNTIME_REASON = 'Renaming the application_settings.repository_storage column' # 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 diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 3865f3e3a08..f4fe8103218 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -25,7 +25,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration end DOWNTIME = true - DOWNTIME_REASON = 'Existing workers will error until they are using a newer version of the code'.freeze + DOWNTIME_REASON = 'Existing workers will error until they are using a newer version of the code' disable_ddl_transaction! diff --git a/db/migrate/20161130095245_fill_routes_table.rb b/db/migrate/20161130095245_fill_routes_table.rb index ccd2cceee0c..c3536d6d911 100644 --- a/db/migrate/20161130095245_fill_routes_table.rb +++ b/db/migrate/20161130095245_fill_routes_table.rb @@ -5,7 +5,7 @@ class FillRoutesTable < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'No new namespaces should be created during data copy'.freeze + DOWNTIME_REASON = 'No new namespaces should be created during data copy' def up execute <<-EOF diff --git a/db/migrate/20161130101252_fill_projects_routes_table.rb b/db/migrate/20161130101252_fill_projects_routes_table.rb index 5e7d0e75ad8..56ba6fcdbe3 100644 --- a/db/migrate/20161130101252_fill_projects_routes_table.rb +++ b/db/migrate/20161130101252_fill_projects_routes_table.rb @@ -5,7 +5,7 @@ class FillProjectsRoutesTable < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'No new projects should be created during data copy'.freeze + DOWNTIME_REASON = 'No new projects should be created during data copy' def up if Gitlab::Database.postgresql? diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb index afd5ce95068..3ae3f2c159b 100644 --- a/db/migrate/20161201160452_migrate_project_statistics.rb +++ b/db/migrate/20161201160452_migrate_project_statistics.rb @@ -2,7 +2,7 @@ class MigrateProjectStatistics < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Removes two columns from the projects table'.freeze + DOWNTIME_REASON = 'Removes two columns from the projects table' def up # convert repository_size in float (megabytes) to integer (bytes), diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index b31f9699f3d..f73e4f6c99b 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -2,7 +2,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Renaming non-unique environments'.freeze + DOWNTIME_REASON = 'Renaming non-unique environments' def up environments = Arel::Table.new(:environments) @@ -42,10 +42,10 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration conflicts.each do |id, name| update_sql = Arel::UpdateManager.new(ActiveRecord::Base) - .table(environments) - .set(environments[:name] => name + "-" + id.to_s) - .where(environments[:id].eq(id)) - .to_sql + .table(environments) + .set(environments[:name] => name + "-" + id.to_s) + .where(environments[:id].eq(id)) + .to_sql connection.exec_update(update_sql, self.class.name, []) end diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb index 94fa3b6838c..ac680c8d10f 100644 --- a/db/migrate/20161207231621_create_environment_name_unique_index.rb +++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb @@ -4,7 +4,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration disable_ddl_transaction! DOWNTIME = true - DOWNTIME_REASON = 'Making a non-unique index into a unique index'.freeze + DOWNTIME_REASON = 'Making a non-unique index into a unique index' def up remove_index :environments, [:project_id, :name] diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 1dec96a1299..83cdd484c4c 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -5,7 +5,7 @@ class AddEnvironmentSlug < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data'.freeze + DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data' # Used to generate random suffixes for the slug LETTERS = 'a'..'z' diff --git a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb index fbf6e4c2a45..e9fcef1cd45 100644 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb @@ -5,7 +5,7 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = 'Adding a *unique* index to environments.slug'.freeze + DOWNTIME_REASON = 'Adding a *unique* index to environments.slug' disable_ddl_transaction! diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb index 2b2b7ab27ce..69bfa2d3fc4 100644 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb @@ -9,7 +9,7 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration # 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 = ''.freeze + 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 diff --git a/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb index eacc6d1b033..319d86ac159 100644 --- a/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb +++ b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb @@ -2,7 +2,7 @@ class RemoveInactiveJiraServiceProperties < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = true - DOWNTIME_REASON = "Removes all inactive jira_service properties".freeze + DOWNTIME_REASON = "Removes all inactive jira_service properties" def up execute("UPDATE services SET properties = '{}' WHERE services.type = 'JiraService' and services.active = false") diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb index 823274b08c0..69007b8e8ed 100644 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -14,15 +14,15 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration finder_sql = projects - .join(namespaces, Arel::Nodes::InnerJoin) - .on(projects[:namespace_id].eq(namespaces[:id])) - .where(projects[:visibility_level].gt(namespaces[:visibility_level])) - .project(projects[:id], namespaces[:visibility_level]) - .take(BATCH_SIZE) - .to_sql + .join(namespaces, Arel::Nodes::InnerJoin) + .on(projects[:namespace_id].eq(namespaces[:id])) + .where(projects[:visibility_level].gt(namespaces[:visibility_level])) + .project(projects[:id], namespaces[:visibility_level]) + .take(BATCH_SIZE) + .to_sql # Update matching rows in batches. Each batch can cause up to 3 UPDATE - # statements, in addition to the SELECT: one per visibility_level + # statements, in addition to the SELECT: one per visibility_level loop do to_update = connection.exec_query(finder_sql) break if to_update.rows.count == 0 -- cgit v1.2.3 From bdbc7d967a0c3d95d5e4ea19a2a5be41268d3540 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 22 Feb 2017 16:39:43 -0600 Subject: Revert "Enable Style/BarePercentLiterals" This reverts commit 96bef54154e669f9a3e92c3a4bc76c0be3a52e48. --- db/migrate/20160610201627_migrate_users_notification_level.rb | 4 ++-- db/migrate/20160831214543_migrate_project_features.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb index 9da67b59dd1..ce4f00e25fa 100644 --- a/db/migrate/20160610201627_migrate_users_notification_level.rb +++ b/db/migrate/20160610201627_migrate_users_notification_level.rb @@ -5,7 +5,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration DOWNTIME = false def up - execute(%{ + execute(%Q{ INSERT INTO notification_settings (user_id, level, created_at, updated_at) (SELECT id, notification_level, created_at, updated_at FROM users WHERE notification_level != 1) @@ -15,7 +15,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration # Migrates from notification settings back to user notification_level # If no value is found the default level of 1 will be used def down - execute(%{ + execute(%Q{ UPDATE users u SET notification_level = COALESCE((SELECT level FROM notification_settings WHERE user_id = u.id AND source_type IS NULL), 1) }) diff --git a/db/migrate/20160831214543_migrate_project_features.rb b/db/migrate/20160831214543_migrate_project_features.rb index a2f2267773c..79a5fb29d64 100644 --- a/db/migrate/20160831214543_migrate_project_features.rb +++ b/db/migrate/20160831214543_migrate_project_features.rb @@ -10,7 +10,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration def up sql = - %{ + %Q{ INSERT INTO project_features(project_id, issues_access_level, merge_requests_access_level, wiki_access_level, builds_access_level, snippets_access_level, created_at, updated_at) SELECT @@ -29,7 +29,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration end def down - sql = %{ + sql = %Q{ UPDATE projects SET issues_enabled = COALESCE((SELECT CASE WHEN issues_access_level = 20 THEN true ELSE false END AS issues_enabled FROM project_features WHERE project_features.project_id = projects.id), true), -- cgit v1.2.3 From 1fe7501b49f896b74102c4b970310aa9ae34da85 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 22 Feb 2017 16:50:15 -0600 Subject: Revert "Prefer leading style for Style/DotPosition" This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b. --- ...124141322_migrate_process_commit_worker_jobs.rb | 6 ++-- ...1207231620_fixup_environment_name_uniqueness.rb | 32 +++++++++++----------- db/migrate/20161207231626_add_environment_slug.rb | 8 +++--- ..._fix_project_records_with_invalid_visibility.rb | 22 +++++++-------- ...20161221153951_rename_reserved_project_names.rb | 12 ++++---- ...170104150317_requeue_pending_delete_projects.rb | 12 ++++---- .../20170106142508_fill_authorized_projects.rb | 4 +-- 7 files changed, 48 insertions(+), 48 deletions(-) (limited to 'db') diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index f4fe8103218..3e1f6b1627d 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -6,9 +6,9 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration class Project < ActiveRecord::Base def self.find_including_path(id) - select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace") - .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id') - .find_by(id: id) + select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace"). + joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id'). + find_by(id: id) end def repository_storage_path diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb index f73e4f6c99b..a20a903a752 100644 --- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb +++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb @@ -8,11 +8,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration environments = Arel::Table.new(:environments) # Get all [project_id, name] pairs that occur more than once - finder_sql = environments - .group(environments[:project_id], environments[:name]) - .having(Arel.sql("COUNT(1)").gt(1)) - .project(environments[:project_id], environments[:name]) - .to_sql + finder_sql = environments. + group(environments[:project_id], environments[:name]). + having(Arel.sql("COUNT(1)").gt(1)). + project(environments[:project_id], environments[:name]). + to_sql conflicting = connection.exec_query(finder_sql) @@ -28,12 +28,12 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration # Rename conflicting environments by appending "-#{id}" to all but the first def fix_duplicates(project_id, name) environments = Arel::Table.new(:environments) - finder_sql = environments - .where(environments[:project_id].eq(project_id)) - .where(environments[:name].eq(name)) - .order(environments[:id].asc) - .project(environments[:id], environments[:name]) - .to_sql + finder_sql = environments. + where(environments[:project_id].eq(project_id)). + where(environments[:name].eq(name)). + order(environments[:id].asc). + project(environments[:id], environments[:name]). + to_sql # Now we have the data for all the conflicting rows conflicts = connection.exec_query(finder_sql).rows @@ -41,11 +41,11 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration conflicts.each do |id, name| update_sql = - Arel::UpdateManager.new(ActiveRecord::Base) - .table(environments) - .set(environments[:name] => name + "-" + id.to_s) - .where(environments[:id].eq(id)) - .to_sql + Arel::UpdateManager.new(ActiveRecord::Base). + table(environments). + set(environments[:name] => name + "-" + id.to_s). + where(environments[:id].eq(id)). + to_sql connection.exec_update(update_sql, self.class.name, []) end diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb index 83cdd484c4c..8e98ee5b9ba 100644 --- a/db/migrate/20161207231626_add_environment_slug.rb +++ b/db/migrate/20161207231626_add_environment_slug.rb @@ -19,10 +19,10 @@ class AddEnvironmentSlug < ActiveRecord::Migration finder = environments.project(:id, :name) connection.exec_query(finder.to_sql).rows.each do |id, name| - updater = Arel::UpdateManager.new(ActiveRecord::Base) - .table(environments) - .set(environments[:slug] => generate_slug(name)) - .where(environments[:id].eq(id)) + updater = Arel::UpdateManager.new(ActiveRecord::Base). + table(environments). + set(environments[:slug] => generate_slug(name)). + where(environments[:id].eq(id)) connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb index 69007b8e8ed..14b5ef476f0 100644 --- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -13,13 +13,13 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration namespaces = Arel::Table.new(:namespaces) finder_sql = - projects - .join(namespaces, Arel::Nodes::InnerJoin) - .on(projects[:namespace_id].eq(namespaces[:id])) - .where(projects[:visibility_level].gt(namespaces[:visibility_level])) - .project(projects[:id], namespaces[:visibility_level]) - .take(BATCH_SIZE) - .to_sql + projects. + join(namespaces, Arel::Nodes::InnerJoin). + on(projects[:namespace_id].eq(namespaces[:id])). + where(projects[:visibility_level].gt(namespaces[:visibility_level])). + project(projects[:id], namespaces[:visibility_level]). + take(BATCH_SIZE). + to_sql # Update matching rows in batches. Each batch can cause up to 3 UPDATE # statements, in addition to the SELECT: one per visibility_level @@ -33,10 +33,10 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration end updates.each do |visibility_level, project_ids| - updater = Arel::UpdateManager.new(ActiveRecord::Base) - .table(projects) - .set(projects[:visibility_level] => visibility_level) - .where(projects[:id].in(project_ids)) + updater = Arel::UpdateManager.new(ActiveRecord::Base). + table(projects). + set(projects[:visibility_level] => visibility_level). + where(projects[:id].in(project_ids)) ActiveRecord::Base.connection.exec_update(updater.to_sql, self.class.name, []) end diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb index d322844e2fd..49a6bc884a8 100644 --- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb +++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb @@ -79,17 +79,17 @@ class RenameReservedProjectNames < ActiveRecord::Migration 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) + 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) - ActiveRecord::Base.connection - .select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? + ActiveRecord::Base.connection. + select_all("SELECT id, path FROM routes WHERE path = '#{quoted_path}'").present? end # Adds number to the end of the path that is not taken by other route diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb index d7be004d47f..f399950bd5e 100644 --- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb +++ b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb @@ -39,11 +39,11 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration def find_batch projects = Arel::Table.new(:projects) - projects.project(projects[:id]) - .where(projects[:pending_delete].eq(true)) - .where(projects[:namespace_id].not_eq(nil)) - .skip(@offset * BATCH_SIZE) - .take(BATCH_SIZE) - .to_sql + projects.project(projects[:id]). + where(projects[:pending_delete].eq(true)). + where(projects[:namespace_id].not_eq(nil)). + skip(@offset * BATCH_SIZE). + take(BATCH_SIZE). + to_sql end end diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb index 0ca20587981..314c8440c8b 100644 --- a/db/post_migrate/20170106142508_fill_authorized_projects.rb +++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb @@ -15,8 +15,8 @@ class FillAuthorizedProjects < ActiveRecord::Migration disable_ddl_transaction! def up - relation = User.select(:id) - .where('authorized_projects_populated IS NOT TRUE') + relation = User.select(:id). + where('authorized_projects_populated IS NOT TRUE') relation.find_in_batches(batch_size: 1_000) do |rows| args = rows.map { |row| [row.id] } -- cgit v1.2.3 From 8e684809765fa866a125c176327825ebc565f5b3 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 6 Feb 2017 17:37:05 +0530 Subject: Use a `ghost` boolean to track ghost users. Rather than using a separate `ghost` state. This lets us have the benefits of both ghost and blocked users (ghost: true, state: blocked) without having to rewrite a number of queries to include cases for `state: ghost`. --- db/migrate/20170206115204_add_column_ghost_to_users.rb | 15 +++++++++++++++ db/schema.rb | 1 + 2 files changed, 16 insertions(+) create mode 100644 db/migrate/20170206115204_add_column_ghost_to_users.rb (limited to 'db') diff --git a/db/migrate/20170206115204_add_column_ghost_to_users.rb b/db/migrate/20170206115204_add_column_ghost_to_users.rb new file mode 100644 index 00000000000..57b66ca91a8 --- /dev/null +++ b/db/migrate/20170206115204_add_column_ghost_to_users.rb @@ -0,0 +1,15 @@ +class AddColumnGhostToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default :users, :ghost, :boolean, default: false, allow_null: false + end + + def down + remove_column :users, :ghost + end +end diff --git a/db/schema.rb b/db/schema.rb index 82bccda580a..c50d6fc4ad6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1282,6 +1282,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.string "incoming_email_token" t.boolean "authorized_projects_populated" t.boolean "notified_of_own_activity", default: false, null: false + t.boolean "ghost", default: false, null: false end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.3 From 3bd2a98f64a12a2e23a6b9ce77427a9c2033a6bf Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 7 Feb 2017 12:13:24 +0530 Subject: Remove the default value for the `users.ghost` database column. The default (false) is not strictly required, and this lets us avoid a potentially expensive migration --- db/migrate/20170206115204_add_column_ghost_to_users.rb | 6 +----- db/schema.rb | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/migrate/20170206115204_add_column_ghost_to_users.rb b/db/migrate/20170206115204_add_column_ghost_to_users.rb index 57b66ca91a8..cc1eeda1160 100644 --- a/db/migrate/20170206115204_add_column_ghost_to_users.rb +++ b/db/migrate/20170206115204_add_column_ghost_to_users.rb @@ -1,12 +1,8 @@ class AddColumnGhostToUsers < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - DOWNTIME = false - disable_ddl_transaction! - def up - add_column_with_default :users, :ghost, :boolean, default: false, allow_null: false + add_column :users, :ghost, :boolean end def down diff --git a/db/schema.rb b/db/schema.rb index c50d6fc4ad6..1d94368f66e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1278,11 +1278,11 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.datetime "otp_grace_period_started_at" t.boolean "ldap_email", default: false, null: false t.boolean "external", default: false - t.string "organization" t.string "incoming_email_token" + t.string "organization" t.boolean "authorized_projects_populated" t.boolean "notified_of_own_activity", default: false, null: false - t.boolean "ghost", default: false, null: false + t.boolean "ghost" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.3 From 9f0e23d6093d67d368485e2ac7e4df0059935770 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Fri, 24 Feb 2017 13:25:42 +0100 Subject: Fix tests --- db/migrate/20170120131253_create_chat_teams.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb index 6476c239152..2d9341d235f 100644 --- a/db/migrate/20170120131253_create_chat_teams.rb +++ b/db/migrate/20170120131253_create_chat_teams.rb @@ -1,7 +1,8 @@ class CreateChatTeams < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - DOWNTIME = false + DOWNTIME = true + DOWNTIME_REASON = "Adding a foreign key" def change create_table :chat_teams do |t| @@ -12,6 +13,6 @@ class CreateChatTeams < ActiveRecord::Migration t.timestamps null: false end - add_foreign_key :chat_teams, :namespaces, on_delete: :cascade + add_concurrent_foreign_key :chat_teams, :namespaces, on_delete: :cascade end end -- cgit v1.2.3 From 0625af3bcb75b3186a3286eee662a7ff8442f130 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 13 Feb 2017 15:09:36 -0600 Subject: Consistently create, update, and delete files, taking CRLF settings into account --- db/fixtures/development/17_cycle_analytics.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'db') diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 747901dd634..647ed75b6d1 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -155,17 +155,9 @@ class Gitlab::Seeder::CycleAnalytics issue.project.repository.add_branch(@user, branch_name, 'master') - options = { - committer: issue.project.repository.user_to_committer(@user), - author: issue.project.repository.user_to_committer(@user), - commit: { message: "Commit for ##{issue.iid}", branch: branch_name, update_ref: true }, - file: { content: "content", path: filename, update: false } - } - - commit_sha = Gitlab::Git::Blob.commit(issue.project.repository, options) + commit_sha = issue.project.repository.commit_file(@user, filename, "content", options, message: "Commit for ##{issue.iid}", branch_name: branch_name) issue.project.repository.commit(commit_sha) - GitPushService.new(issue.project, @user, oldrev: issue.project.repository.commit("master").sha, -- cgit v1.2.3 From faa2e2df8fb95655ebfb8523689295e223005d9d Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 15 Feb 2017 17:28:29 -0600 Subject: Rename commit_file, commit_dir and remove_file and update specs --- 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 647ed75b6d1..aea0a72b633 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -155,7 +155,7 @@ class Gitlab::Seeder::CycleAnalytics issue.project.repository.add_branch(@user, branch_name, 'master') - commit_sha = issue.project.repository.commit_file(@user, filename, "content", options, message: "Commit for ##{issue.iid}", branch_name: branch_name) + commit_sha = issue.project.repository.create_file(@user, filename, "content", options, message: "Commit for ##{issue.iid}", branch_name: branch_name) issue.project.repository.commit(commit_sha) GitPushService.new(issue.project, -- cgit v1.2.3 From 34bf798eb85635b7cdc3405ab75955f88be6e157 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Mon, 27 Feb 2017 13:40:26 +0200 Subject: [Issue ordering] Using integer instead of float --- db/migrate/20170131221752_add_relative_position_to_issues.rb | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170131221752_add_relative_position_to_issues.rb b/db/migrate/20170131221752_add_relative_position_to_issues.rb index 41e17cf13ba..4f0cd803308 100644 --- a/db/migrate/20170131221752_add_relative_position_to_issues.rb +++ b/db/migrate/20170131221752_add_relative_position_to_issues.rb @@ -24,7 +24,7 @@ class AddRelativePositionToIssues < ActiveRecord::Migration # disable_ddl_transaction! def change - add_column :issues, :relative_position, :float + add_column :issues, :relative_position, :integer add_index :issues, :relative_position end diff --git a/db/schema.rb b/db/schema.rb index 9e814ebdbd2..c2723cf893f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -515,7 +515,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.text "title_html" t.text "description_html" t.integer "time_estimate" - t.float "relative_position" + t.integer "relative_position" end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree -- cgit v1.2.3 From 74faf4ca517200c5458e88d5f5b908d074bf64c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 27 Feb 2017 17:28:53 +0200 Subject: Add development fixtures for nested groups Signed-off-by: Dmitriy Zaporozhets --- db/fixtures/development/19_nested_groups.rb | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 db/fixtures/development/19_nested_groups.rb (limited to 'db') diff --git a/db/fixtures/development/19_nested_groups.rb b/db/fixtures/development/19_nested_groups.rb new file mode 100644 index 00000000000..d8dddc3fee9 --- /dev/null +++ b/db/fixtures/development/19_nested_groups.rb @@ -0,0 +1,69 @@ +require './spec/support/sidekiq' + +def create_group_with_parents(user, full_path) + parent_path = nil + group = nil + + until full_path.blank? + path, _, full_path = full_path.partition('/') + + if parent_path + parent = Group.find_by_full_path(parent_path) + + parent_path += '/' + parent_path += path + + group = Groups::CreateService.new(user, path: path, parent_id: parent.id).execute + else + parent_path = path + + group = Group.find_by_full_path(parent_path) || + Groups::CreateService.new(user, path: path).execute + end + end + + group +end + +Sidekiq::Testing.inline! do + Gitlab::Seeder.quiet do + project_urls = [ + 'https://android.googlesource.com/platform/hardware/broadcom/libbt.git', + 'https://android.googlesource.com/platform/hardware/broadcom/wlan.git', + 'https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git', + 'https://android.googlesource.com/platform/hardware/bsp/broadcom.git', + 'https://android.googlesource.com/platform/hardware/bsp/freescale.git', + 'https://android.googlesource.com/platform/hardware/bsp/imagination.git', + 'https://android.googlesource.com/platform/hardware/bsp/intel.git', + 'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git', + 'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git' + ] + + user = User.admins.first + + project_urls.each_with_index do |url, i| + full_path = url.sub('https://android.googlesource.com/', '') + full_path = full_path.sub(/\.git\z/, '') + full_path, _, project_path = full_path.rpartition('/') + group = Group.find_by_full_path(full_path) || create_group_with_parents(user, full_path) + + params = { + import_url: url, + namespace_id: group.id, + path: project_path, + name: project_path, + description: FFaker::Lorem.sentence, + visibility_level: Gitlab::VisibilityLevel.values.sample + } + + project = Projects::CreateService.new(user, params).execute + project.send(:_run_after_commit_queue) + + if project.valid? + print '.' + else + print 'F' + end + end + end +end -- cgit v1.2.3 From eb90e3278ae2fa516e3b6a30ff2fad23ae668c9b Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Tue, 28 Feb 2017 00:38:37 -0500 Subject: Fix migration without DOWNTIME clause specified --- db/migrate/20160610201627_migrate_users_notification_level.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'db') diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb index ce4f00e25fa..cd8b505de9f 100644 --- a/db/migrate/20160610201627_migrate_users_notification_level.rb +++ b/db/migrate/20160610201627_migrate_users_notification_level.rb @@ -1,4 +1,6 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration + DOWNTIME = false + # Migrates only users who changed their default notification level :participating # creating a new record on notification settings table -- cgit v1.2.3 From 8708347c244e2fb57912a70b5bece251f7b16ef4 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 28 Feb 2017 20:47:36 +0200 Subject: Recover db/schema.rb --- db/schema.rb | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 7430bd0f918..205299dbb5a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -87,9 +87,9 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.boolean "send_user_confirmation_email", default: false t.integer "container_registry_token_expire_delay", default: 5 t.text "after_sign_up_text" + t.boolean "user_default_external", default: false, null: false t.string "repository_storages", default: "default" t.string "enabled_git_access_protocol" - t.boolean "user_default_external", default: false, null: false t.boolean "domain_blacklist_enabled", default: false t.text "domain_blacklist" t.boolean "koding_enabled" @@ -403,22 +403,22 @@ ActiveRecord::Schema.define(version: 20170216141440) do add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree create_table "deployments", force: :cascade do |t| - t.integer "iid" - t.integer "project_id" - t.integer "environment_id" - t.string "ref" - t.boolean "tag" - t.string "sha" + t.integer "iid", null: false + t.integer "project_id", null: false + t.integer "environment_id", null: false + t.string "ref", null: false + t.boolean "tag", null: false + t.string "sha", null: false t.integer "user_id" - t.integer "deployable_id", null: false - t.string "deployable_type", null: false + t.integer "deployable_id" + t.string "deployable_type" t.datetime "created_at" t.datetime "updated_at" t.string "on_stop" end 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", using: :btree + add_index "deployments", ["project_id", "iid"], name: "index_deployments_on_project_id_and_iid", unique: true, using: :btree create_table "emails", force: :cascade do |t| t.integer "user_id", null: false @@ -695,8 +695,8 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.integer "merge_user_id" t.string "merge_commit_sha" t.datetime "deleted_at" - t.integer "lock_version" t.string "in_progress_merge_commit_sha" + t.integer "lock_version" t.text "title_html" t.text "description_html" t.integer "time_estimate" @@ -773,16 +773,6 @@ ActiveRecord::Schema.define(version: 20170216141440) do add_index "namespaces", ["path"], name: "index_namespaces_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree - create_table "note_templates", force: :cascade do |t| - t.integer "user_id" - t.string "title" - t.text "note" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - add_index "note_templates", ["user_id"], name: "index_note_templates_on_user_id", using: :btree - create_table "notes", force: :cascade do |t| t.text "note" t.string "noteable_type" @@ -798,7 +788,6 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.text "st_diff" t.integer "updated_by_id" t.string "type" - t.string "system_type" t.text "position" t.text "original_position" t.datetime "resolved_at" @@ -992,7 +981,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.boolean "has_external_wiki" t.boolean "lfs_enabled" t.text "description_html" - t.boolean "only_allow_merge_if_all_discussions_are_resolved", default: false, null: false + t.boolean "only_allow_merge_if_all_discussions_are_resolved" end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree -- cgit v1.2.3 From 81246e5649a8fb9e73369cbd117505a546d7e807 Mon Sep 17 00:00:00 2001 From: Simon Vocella Date: Tue, 27 Dec 2016 17:26:57 +0100 Subject: manage personal_access_tokens through api --- ...nge_expires_at_to_date_in_personal_access_tokens.rb | 18 ++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb (limited to 'db') diff --git a/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb b/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb new file mode 100644 index 00000000000..af1bac897cc --- /dev/null +++ b/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class ChangeExpiresAtToDateInPersonalAccessTokens < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = true + DOWNTIME_REASON = 'This migration requires downtime because it alters expires_at column from datetime to date' + + def up + change_column :personal_access_tokens, :expires_at, :date + end + + def down + change_column :personal_access_tokens, :expires_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 1d94368f66e..82b4a931069 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -879,7 +879,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.string "token", null: false t.string "name", null: false t.boolean "revoked", default: false - t.datetime "expires_at" + t.date "expires_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "scopes", default: "--- []\n", null: false -- cgit v1.2.3 From a3dfb58e7f1b1a3df4a4c16b2d09e50831370a69 Mon Sep 17 00:00:00 2001 From: Simon Vocella Date: Wed, 28 Dec 2016 17:19:08 +0100 Subject: add impersonation token --- ...5550_add_impersonation_to_personal_access_tokens.rb | 18 ++++++++++++++++++ db/schema.rb | 1 + 2 files changed, 19 insertions(+) create mode 100644 db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb (limited to 'db') diff --git a/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb b/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb new file mode 100644 index 00000000000..c16d508e141 --- /dev/null +++ b/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddImpersonationToPersonalAccessTokens < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + add_column_with_default :personal_access_tokens, :impersonation, :boolean, default: false + end + + def down + remove_column :personal_access_tokens, :impersonation + end +end diff --git a/db/schema.rb b/db/schema.rb index 82b4a931069..ec2b09f9b7b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -883,6 +883,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "scopes", default: "--- []\n", null: false + t.boolean "impersonation", default: false, null: false end add_index "personal_access_tokens", ["token"], name: "index_personal_access_tokens_on_token", unique: true, using: :btree -- cgit v1.2.3 From 9f2e4742e354f5548b4956060f1bfa5ee3bd6657 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Thu, 23 Feb 2017 17:47:06 +0000 Subject: applies relevant changes to the code and code structure --- .../20161228135550_add_impersonation_to_personal_access_tokens.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb b/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb index c16d508e141..48648043dbb 100644 --- a/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb +++ b/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb @@ -9,7 +9,7 @@ class AddImpersonationToPersonalAccessTokens < ActiveRecord::Migration DOWNTIME = false def up - add_column_with_default :personal_access_tokens, :impersonation, :boolean, default: false + add_column_with_default :personal_access_tokens, :impersonation, :boolean, default: false, null: false end def down -- cgit v1.2.3 From a0101ebf84ed397899df8f3a017d2b25dc45db57 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 17 Feb 2017 14:56:13 +0100 Subject: Update occurrences of MWBS to MWPS Rename column in the database Rename fields related to import/export feature Rename API endpoints Rename documentation links Rename the rest of occurrences in the code Replace the images that contain the words "build succeeds" and docs referencing to them Make sure pipeline is green and nothing is missing. updated doc images renamed only_allow_merge_if_build_succeeds in projects and fixed references more updates fix some spec failures fix rubocop offences fix v3 api spec fix MR specs fixed issues with partials fix MR spec fix alignment add missing v3 to v4 doc wip - refactor v3 endpoints fix specs fix a few typos fix project specs copy entities fully to V3 fix entity error more fixes fix failing specs fixed missing entities in V3 API remove comment updated code based on feedback typo fix spec --- ...70217132157_rename_merge_when_build_succeeds.rb | 29 ++++++++++++++++++++++ ...47_rename_only_allow_merge_if_build_succeeds.rb | 29 ++++++++++++++++++++++ db/schema.rb | 6 ++--- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20170217132157_rename_merge_when_build_succeeds.rb create mode 100644 db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb (limited to 'db') diff --git a/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb b/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb new file mode 100644 index 00000000000..9011526565d --- /dev/null +++ b/db/migrate/20170217132157_rename_merge_when_build_succeeds.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 RenameMergeWhenBuildSucceeds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = true + + # 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 = 'Renaming the column merge_when_build_succeeds' + + # 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 change + rename_column :merge_requests, :merge_when_build_succeeds, :merge_when_pipeline_succeeds + end +end diff --git a/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb b/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb new file mode 100644 index 00000000000..b2b68ff72d1 --- /dev/null +++ b/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.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 RenameOnlyAllowMergeIfBuildSucceeds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = true + + # 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 = 'Renaming the column only_allow_merge_if_build_succeeds' + + # 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 change + rename_column :projects, :only_allow_merge_if_build_succeeds, :only_allow_merge_if_pipeline_succeeds + end +end diff --git a/db/schema.rb b/db/schema.rb index 1d94368f66e..cd5aa339269 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: 20170216141440) do +ActiveRecord::Schema.define(version: 20170217151947) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -689,7 +689,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.integer "updated_by_id" t.text "merge_error" t.text "merge_params" - t.boolean "merge_when_build_succeeds", default: false, null: false + t.boolean "merge_when_pipeline_succeeds", default: false, null: false t.integer "merge_user_id" t.string "merge_commit_sha" t.datetime "deleted_at" @@ -972,7 +972,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.boolean "last_repository_check_failed" t.datetime "last_repository_check_at" t.boolean "container_registry_enabled" - t.boolean "only_allow_merge_if_build_succeeds", default: false, null: false + t.boolean "only_allow_merge_if_pipeline_succeeds", default: false, null: false t.boolean "has_external_issue_tracker" t.string "repository_storage", default: "default", null: false t.boolean "request_access_enabled", default: false, null: false -- cgit v1.2.3 From 2f40fc521e572fb4043cfa5e57616b4e5214033a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 1 Mar 2017 11:26:44 +0100 Subject: Disable the inheritance column of services in DisableInvalidServiceTemplates migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `unless defined?(Service)` was useless since in production env, models are eager loaded, thus we wouldn't disable the STI, resulting in the following error: The single-table inheritance mechanism failed to locate the subclass: 'GitlabCiService'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Service.inheritance_column to use another column for that information./opt/gitlab/embedded/service/gitlab-rails/db/post_migrate/20170211073944_disable_invalid_service_templates.rb:11:in `up' Signed-off-by: Rémy Coutable --- db/post_migrate/20170211073944_disable_invalid_service_templates.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb index 84954b1ef64..603efc43782 100644 --- a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb +++ b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb @@ -1,10 +1,8 @@ class DisableInvalidServiceTemplates < ActiveRecord::Migration DOWNTIME = false - unless defined?(Service) - class Service < ActiveRecord::Base - self.inheritance_column = nil - end + class Service < ActiveRecord::Base + self.inheritance_column = nil end def up -- cgit v1.2.3 From 52c4a7866ed010d8db67e5ca976d8c73d4084784 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Wed, 1 Mar 2017 20:34:29 +0100 Subject: Improve UX --- db/migrate/20170120131253_create_chat_teams.rb | 4 +++- db/schema.rb | 14 ++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb index 2d9341d235f..699226d60c9 100644 --- a/db/migrate/20170120131253_create_chat_teams.rb +++ b/db/migrate/20170120131253_create_chat_teams.rb @@ -4,6 +4,8 @@ class CreateChatTeams < ActiveRecord::Migration DOWNTIME = true DOWNTIME_REASON = "Adding a foreign key" + disable_ddl_transaction! + def change create_table :chat_teams do |t| t.integer :namespace_id, index: true @@ -13,6 +15,6 @@ class CreateChatTeams < ActiveRecord::Migration t.timestamps null: false end - add_concurrent_foreign_key :chat_teams, :namespaces, on_delete: :cascade + add_concurrent_foreign_key :chat_teams, :namespaces, column: :namespace_id end end diff --git a/db/schema.rb b/db/schema.rb index 39c767a5595..34aa12814c0 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: 20170216141440) do +ActiveRecord::Schema.define(version: 20170217151947) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -61,7 +61,6 @@ ActiveRecord::Schema.define(version: 20170216141440) 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 @@ -110,7 +109,9 @@ ActiveRecord::Schema.define(version: 20170216141440) 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 end create_table "audit_events", force: :cascade do |t| @@ -698,7 +699,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.integer "updated_by_id" t.text "merge_error" t.text "merge_params" - t.boolean "merge_when_build_succeeds", default: false, null: false + t.boolean "merge_when_pipeline_succeeds", default: false, null: false t.integer "merge_user_id" t.string "merge_commit_sha" t.datetime "deleted_at" @@ -765,8 +766,8 @@ ActiveRecord::Schema.define(version: 20170216141440) 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" end @@ -981,7 +982,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.boolean "last_repository_check_failed" t.datetime "last_repository_check_at" t.boolean "container_registry_enabled" - t.boolean "only_allow_merge_if_build_succeeds", default: false, null: false + t.boolean "only_allow_merge_if_pipeline_succeeds", default: false, null: false t.boolean "has_external_issue_tracker" t.string "repository_storage", default: "default", null: false t.boolean "request_access_enabled", default: false, null: false @@ -1291,6 +1292,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "notified_of_own_activity", default: false, null: false + t.boolean "ghost" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree @@ -1341,7 +1343,7 @@ ActiveRecord::Schema.define(version: 20170216141440) do add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree add_foreign_key "boards", "projects" - add_foreign_key "chat_teams", "namespaces", on_delete: :cascade + add_foreign_key "chat_teams", "namespaces", name: "fk_3b543909cb", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade -- cgit v1.2.3 From b64020de281b89f33cbcb6d7642abd76dda31d74 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Thu, 2 Mar 2017 16:58:41 +0200 Subject: Satisfy rubocop --- db/migrate/20170131221752_add_relative_position_to_issues.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170131221752_add_relative_position_to_issues.rb b/db/migrate/20170131221752_add_relative_position_to_issues.rb index 4f0cd803308..28c3d1012ce 100644 --- a/db/migrate/20170131221752_add_relative_position_to_issues.rb +++ b/db/migrate/20170131221752_add_relative_position_to_issues.rb @@ -26,6 +26,6 @@ class AddRelativePositionToIssues < ActiveRecord::Migration def change add_column :issues, :relative_position, :integer - add_index :issues, :relative_position + add_concurrent_index :issues, :relative_position end end -- cgit v1.2.3 From a0ab45d0c3d9625e8cff994173b6441e9623770f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 2 Mar 2017 18:18:50 -0500 Subject: Fix the `Gitlab::Seeder` monkey patch to disable mail delivery --- db/fixtures/development/13_comments.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/fixtures/development/13_comments.rb b/db/fixtures/development/13_comments.rb index 29b8081055d..bc2d74c8034 100644 --- a/db/fixtures/development/13_comments.rb +++ b/db/fixtures/development/13_comments.rb @@ -1,7 +1,7 @@ require './spec/support/sidekiq' Gitlab::Seeder.quiet do - Issue.all.each do |issue| + Issue.find_each do |issue| project = issue.project project.team.users.each do |user| @@ -16,7 +16,7 @@ Gitlab::Seeder.quiet do end end - MergeRequest.all.each do |mr| + MergeRequest.find_each do |mr| project = mr.project project.team.users.each do |user| -- cgit v1.2.3 From 0b9d56f960e272047ac749cff7a29f2b5f03f7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Tue, 28 Feb 2017 18:08:40 -0300 Subject: Update storage settings to allow extra values per shard This will be necessary when adding gitaly settings. This version doesn't make any functional changes, but allows us to include this breaking change in 9.0 and add the needed extra settings in the future with backwards compatibility --- db/migrate/20140502125220_migrate_repo_size.rb | 2 +- db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb | 2 +- db/migrate/20161220141214_remove_dot_git_from_group_names.rb | 2 +- db/migrate/20161226122833_remove_dot_git_from_usernames.rb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'db') diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb index e8de7ccf3db..66203486d53 100644 --- a/db/migrate/20140502125220_migrate_repo_size.rb +++ b/db/migrate/20140502125220_migrate_repo_size.rb @@ -8,7 +8,7 @@ class MigrateRepoSize < ActiveRecord::Migration project_data.each do |project| id = project['id'] namespace_path = project['namespace_path'] || '' - repos_path = Gitlab.config.gitlab_shell['repos_path'] || Gitlab.config.repositories.storages.default + repos_path = Gitlab.config.gitlab_shell['repos_path'] || Gitlab.config.repositories.storages.default['path'] path = File.join(repos_path, namespace_path, project['project_path'] + '.git') begin diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb index 3e1f6b1627d..e5292cfba07 100644 --- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb +++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb @@ -12,7 +12,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration end def repository_storage_path - Gitlab.config.repositories.storages[repository_storage] + Gitlab.config.repositories.storages[repository_storage]['path'] end def repository_path diff --git a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb index 241afc6b097..8fb1f9d5e73 100644 --- a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb +++ b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb @@ -60,7 +60,7 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration def move_namespace(group_id, path_was, path) repository_storage_paths = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map do |row| - Gitlab.config.repositories.storages[row['repository_storage']] + Gitlab.config.repositories.storages[row['repository_storage']]['path'] end.compact # Move the namespace directory in all storages paths used by member projects diff --git a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb index a0ce927161f..61dcc8c54f5 100644 --- a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb +++ b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb @@ -71,7 +71,7 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration route_exists = route_exists?(path) Gitlab.config.repositories.storages.each_value do |storage| - if route_exists || path_exists?(path, storage) + if route_exists || path_exists?(path, storage['path']) counter += 1 path = "#{base}#{counter}" @@ -84,7 +84,7 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration def move_namespace(namespace_id, path_was, path) repository_storage_paths = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map do |row| - Gitlab.config.repositories.storages[row['repository_storage']] + Gitlab.config.repositories.storages[row['repository_storage']]['path'] end.compact # Move the namespace directory in all storages paths used by member projects -- cgit v1.2.3 From 0a75de2909152351483b317024fcab2e9bb08e16 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 15 Feb 2017 19:36:31 +0100 Subject: Make Pipeline Triggers to be user aware - they can have owner, - they can be edited, - they have description, - you can take ownership of them --- db/migrate/20170215164610_add_owner_id_to_triggers.rb | 10 ++++++++++ db/migrate/20170215165036_add_description_to_triggers.rb | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 db/migrate/20170215164610_add_owner_id_to_triggers.rb create mode 100644 db/migrate/20170215165036_add_description_to_triggers.rb (limited to 'db') diff --git a/db/migrate/20170215164610_add_owner_id_to_triggers.rb b/db/migrate/20170215164610_add_owner_id_to_triggers.rb new file mode 100644 index 00000000000..02c77ee4b5e --- /dev/null +++ b/db/migrate/20170215164610_add_owner_id_to_triggers.rb @@ -0,0 +1,10 @@ +class AddOwnerIdToTriggers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_triggers, :owner_id, :integer + add_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :nullify + end +end diff --git a/db/migrate/20170215165036_add_description_to_triggers.rb b/db/migrate/20170215165036_add_description_to_triggers.rb new file mode 100644 index 00000000000..1dca0e37412 --- /dev/null +++ b/db/migrate/20170215165036_add_description_to_triggers.rb @@ -0,0 +1,9 @@ +class AddDescriptionToTriggers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_triggers, :description, :string + end +end -- cgit v1.2.3 From 91ce04678ea78f2042026e8584e5d1069853dbc4 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 5 Mar 2017 18:23:42 +0100 Subject: Make triggers to be user aware --- db/migrate/20170215164610_add_owner_id_to_triggers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170215164610_add_owner_id_to_triggers.rb b/db/migrate/20170215164610_add_owner_id_to_triggers.rb index 02c77ee4b5e..845c89c703e 100644 --- a/db/migrate/20170215164610_add_owner_id_to_triggers.rb +++ b/db/migrate/20170215164610_add_owner_id_to_triggers.rb @@ -5,6 +5,6 @@ class AddOwnerIdToTriggers < ActiveRecord::Migration def change add_column :ci_triggers, :owner_id, :integer - add_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :nullify + add_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade end end -- cgit v1.2.3 From 4ac1467c5ce969e082d96e7b2a60ae8e1654c881 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 5 Mar 2017 18:28:32 +0100 Subject: Update db/schema --- db/migrate/20170215164610_add_owner_id_to_triggers.rb | 10 ---------- db/migrate/20170215165036_add_description_to_triggers.rb | 9 --------- db/migrate/20170217151948_add_owner_id_to_triggers.rb | 10 ++++++++++ db/migrate/20170217151949_add_description_to_triggers.rb | 9 +++++++++ db/schema.rb | 9 ++++++--- 5 files changed, 25 insertions(+), 22 deletions(-) delete mode 100644 db/migrate/20170215164610_add_owner_id_to_triggers.rb delete mode 100644 db/migrate/20170215165036_add_description_to_triggers.rb create mode 100644 db/migrate/20170217151948_add_owner_id_to_triggers.rb create mode 100644 db/migrate/20170217151949_add_description_to_triggers.rb (limited to 'db') diff --git a/db/migrate/20170215164610_add_owner_id_to_triggers.rb b/db/migrate/20170215164610_add_owner_id_to_triggers.rb deleted file mode 100644 index 845c89c703e..00000000000 --- a/db/migrate/20170215164610_add_owner_id_to_triggers.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddOwnerIdToTriggers < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_triggers, :owner_id, :integer - add_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade - end -end diff --git a/db/migrate/20170215165036_add_description_to_triggers.rb b/db/migrate/20170215165036_add_description_to_triggers.rb deleted file mode 100644 index 1dca0e37412..00000000000 --- a/db/migrate/20170215165036_add_description_to_triggers.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddDescriptionToTriggers < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_triggers, :description, :string - end -end diff --git a/db/migrate/20170217151948_add_owner_id_to_triggers.rb b/db/migrate/20170217151948_add_owner_id_to_triggers.rb new file mode 100644 index 00000000000..845c89c703e --- /dev/null +++ b/db/migrate/20170217151948_add_owner_id_to_triggers.rb @@ -0,0 +1,10 @@ +class AddOwnerIdToTriggers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_triggers, :owner_id, :integer + add_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade + end +end diff --git a/db/migrate/20170217151949_add_description_to_triggers.rb b/db/migrate/20170217151949_add_description_to_triggers.rb new file mode 100644 index 00000000000..1dca0e37412 --- /dev/null +++ b/db/migrate/20170217151949_add_description_to_triggers.rb @@ -0,0 +1,9 @@ +class AddDescriptionToTriggers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_triggers, :description, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index cd5aa339269..75daae86a4a 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: 20170217151947) do +ActiveRecord::Schema.define(version: 20170217151949) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -111,7 +111,7 @@ ActiveRecord::Schema.define(version: 20170217151947) do 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.string "default_artifacts_expire_in", default: "0", null: false end create_table "audit_events", force: :cascade do |t| @@ -377,6 +377,8 @@ ActiveRecord::Schema.define(version: 20170217151947) do t.datetime "created_at" t.datetime "updated_at" t.integer "gl_project_id" + t.integer "owner_id" + t.string "description" end add_index "ci_triggers", ["gl_project_id"], name: "index_ci_triggers_on_gl_project_id", using: :btree @@ -581,9 +583,9 @@ ActiveRecord::Schema.define(version: 20170217151947) do end add_index "labels", ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true, using: :btree - add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree add_index "labels", ["title"], name: "index_labels_on_title", using: :btree + add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree create_table "lfs_objects", force: :cascade do |t| t.string "oid", null: false @@ -1333,6 +1335,7 @@ ActiveRecord::Schema.define(version: 20170217151947) do add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree add_foreign_key "boards", "projects" + add_foreign_key "ci_triggers", "users", column: "owner_id", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade -- cgit v1.2.3 From e4a9b8a9e1f4052fde9ecacad73e2f96fdd8d21d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Sun, 5 Mar 2017 21:40:59 +0100 Subject: Move foreign key to separate migration --- db/migrate/20170217151948_add_owner_id_to_triggers.rb | 1 - db/migrate/20170305203726_add_owner_id_foreign_key.rb | 11 +++++++++++ db/schema.rb | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20170305203726_add_owner_id_foreign_key.rb (limited to 'db') diff --git a/db/migrate/20170217151948_add_owner_id_to_triggers.rb b/db/migrate/20170217151948_add_owner_id_to_triggers.rb index 845c89c703e..16d7cc5bed6 100644 --- a/db/migrate/20170217151948_add_owner_id_to_triggers.rb +++ b/db/migrate/20170217151948_add_owner_id_to_triggers.rb @@ -5,6 +5,5 @@ class AddOwnerIdToTriggers < ActiveRecord::Migration def change add_column :ci_triggers, :owner_id, :integer - add_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade end end diff --git a/db/migrate/20170305203726_add_owner_id_foreign_key.rb b/db/migrate/20170305203726_add_owner_id_foreign_key.rb new file mode 100644 index 00000000000..3eece0e2eb5 --- /dev/null +++ b/db/migrate/20170305203726_add_owner_id_foreign_key.rb @@ -0,0 +1,11 @@ +class AddOwnerIdForeignKey < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def change + add_concurrent_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index 75daae86a4a..9deed46530e 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: 20170217151949) do +ActiveRecord::Schema.define(version: 20170305203726) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1335,7 +1335,7 @@ ActiveRecord::Schema.define(version: 20170217151949) do add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree add_foreign_key "boards", "projects" - add_foreign_key "ci_triggers", "users", column: "owner_id", on_delete: :cascade + add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade -- cgit v1.2.3 From b3aae422a6adbc0e46901a0c9dde5b75b791e060 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Mon, 6 Mar 2017 08:55:30 +0100 Subject: Minor edits, incorporate review --- db/migrate/20170120131253_create_chat_teams.rb | 4 +--- db/schema.rb | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'db') diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb index 699226d60c9..7995d383986 100644 --- a/db/migrate/20170120131253_create_chat_teams.rb +++ b/db/migrate/20170120131253_create_chat_teams.rb @@ -8,13 +8,11 @@ class CreateChatTeams < ActiveRecord::Migration def change create_table :chat_teams do |t| - t.integer :namespace_id, index: true + t.references :namespace, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade } t.string :team_id t.string :name t.timestamps null: false end - - add_concurrent_foreign_key :chat_teams, :namespaces, column: :namespace_id end end diff --git a/db/schema.rb b/db/schema.rb index f42b20652a0..43ca05fad8c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -173,14 +173,14 @@ ActiveRecord::Schema.define(version: 20170217151947) do add_index "chat_names", ["user_id", "service_id"], name: "index_chat_names_on_user_id_and_service_id", unique: true, using: :btree create_table "chat_teams", force: :cascade do |t| - t.integer "namespace_id" + t.integer "namespace_id", null: false t.string "team_id" t.string "name" t.datetime "created_at", null: false t.datetime "updated_at", null: false end - add_index "chat_teams", ["namespace_id"], name: "index_chat_teams_on_namespace_id", using: :btree + add_index "chat_teams", ["namespace_id"], name: "index_chat_teams_on_namespace_id", unique: true, using: :btree create_table "ci_application_settings", force: :cascade do |t| t.boolean "all_broken_builds" @@ -1343,7 +1343,7 @@ ActiveRecord::Schema.define(version: 20170217151947) do add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree add_foreign_key "boards", "projects" - add_foreign_key "chat_teams", "namespaces", name: "fk_3b543909cb", on_delete: :cascade + add_foreign_key "chat_teams", "namespaces", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade -- cgit v1.2.3 From 3788f5face7660c43374d85a4fdbeca04e7b8d68 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 6 Mar 2017 10:50:35 +0100 Subject: Add migration for manual actions with skipped status --- .../20170306090835_migrate_legacy_manual_actions.rb | 19 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170306090835_migrate_legacy_manual_actions.rb (limited to 'db') diff --git a/db/migrate/20170306090835_migrate_legacy_manual_actions.rb b/db/migrate/20170306090835_migrate_legacy_manual_actions.rb new file mode 100644 index 00000000000..9020e0d054c --- /dev/null +++ b/db/migrate/20170306090835_migrate_legacy_manual_actions.rb @@ -0,0 +1,19 @@ +class MigrateLegacyManualActions < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + execute <<-EOS + UPDATE ci_builds SET status = 'manual', allow_failure = true + WHERE ci_builds.when = 'manual' AND ci_builds.status = 'skipped'; + EOS + end + + def down + execute <<-EOS + UPDATE ci_builds SET status = 'skipped', allow_failure = false + WHERE ci_builds.when = 'manual' AND ci_builds.status = 'manual'; + EOS + end +end diff --git a/db/schema.rb b/db/schema.rb index cd5aa339269..d034f28c3ca 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: 20170217151947) do +ActiveRecord::Schema.define(version: 20170306090835) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From e5cf3f51fb568361a247d715facb6cd9bb15bb16 Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Mon, 6 Feb 2017 13:48:46 +0100 Subject: Allow limiting logging in users from too many different IPs. --- ...1347_add_unique_ips_limit_to_application_settings.rb | 17 +++++++++++++++++ db/schema.rb | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb b/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb new file mode 100644 index 00000000000..2aa305f6b58 --- /dev/null +++ b/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb @@ -0,0 +1,17 @@ +class AddUniqueIpsLimitToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + disable_ddl_transaction! + + def up + add_column_with_default(:application_settings, :unique_ips_limit_per_user, :integer, default: 10) + add_column_with_default(:application_settings, :unique_ips_limit_time_window, :integer, default: 3600) + add_column_with_default(:application_settings, :unique_ips_limit_enabled, :boolean, default: false) + end + + def down + remove_column(:application_settings, :unique_ips_limit_per_user) + remove_column(:application_settings, :unique_ips_limit_time_window) + remove_column(:application_settings, :unique_ips_limit_enabled) + end +end diff --git a/db/schema.rb b/db/schema.rb index 9deed46530e..8aed4e13b28 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -112,6 +112,9 @@ ActiveRecord::Schema.define(version: 20170305203726) do 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", default: 10, null: false + t.integer "unique_ips_limit_time_window", default: 3600, null: false + t.boolean "unique_ips_limit_enabled", default: false, null: false end create_table "audit_events", force: :cascade do |t| @@ -252,8 +255,8 @@ ActiveRecord::Schema.define(version: 20170305203726) do t.integer "lock_version" end - add_index "ci_commits", ["gl_project_id", "ref", "status"], name: "index_ci_commits_on_gl_project_id_and_ref_and_status", using: :btree add_index "ci_commits", ["gl_project_id", "sha"], name: "index_ci_commits_on_gl_project_id_and_sha", using: :btree + add_index "ci_commits", ["gl_project_id", "status"], name: "index_ci_commits_on_gl_project_id_and_status", using: :btree add_index "ci_commits", ["gl_project_id"], name: "index_ci_commits_on_gl_project_id", using: :btree add_index "ci_commits", ["status"], name: "index_ci_commits_on_status", using: :btree add_index "ci_commits", ["user_id"], name: "index_ci_commits_on_user_id", using: :btree -- cgit v1.2.3 From 0ef8a643489ad1a3da4431155326f0a6e206d870 Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Mon, 20 Feb 2017 15:09:05 +0100 Subject: Remove unecessary calls to limit_user!, UniqueIps Middleware, and address MR review - cleanup formating in haml - clarify time window is in seconds - cleanup straneous chunks in db/schema - rename count_uniqe_ips to update_and_return_ips_count - other --- ...210131347_add_unique_ips_limit_to_application_settings.rb | 12 ++++++------ db/schema.rb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb b/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb index 2aa305f6b58..cbcf9a30b3c 100644 --- a/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb +++ b/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb @@ -4,14 +4,14 @@ class AddUniqueIpsLimitToApplicationSettings < ActiveRecord::Migration disable_ddl_transaction! def up - add_column_with_default(:application_settings, :unique_ips_limit_per_user, :integer, default: 10) - add_column_with_default(:application_settings, :unique_ips_limit_time_window, :integer, default: 3600) - add_column_with_default(:application_settings, :unique_ips_limit_enabled, :boolean, default: false) + add_column_with_default :application_settings, :unique_ips_limit_per_user, :integer, default: 10 + add_column_with_default :application_settings, :unique_ips_limit_time_window, :integer, default: 3600 + add_column_with_default :application_settings, :unique_ips_limit_enabled, :boolean, default: false end def down - remove_column(:application_settings, :unique_ips_limit_per_user) - remove_column(:application_settings, :unique_ips_limit_time_window) - remove_column(:application_settings, :unique_ips_limit_enabled) + remove_column :application_settings, :unique_ips_limit_per_user + remove_column :application_settings, :unique_ips_limit_time_window + remove_column :application_settings, :unique_ips_limit_enabled end end diff --git a/db/schema.rb b/db/schema.rb index 8aed4e13b28..be54b177fa6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -586,9 +586,9 @@ ActiveRecord::Schema.define(version: 20170305203726) do end add_index "labels", ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true, using: :btree + add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree add_index "labels", ["title"], name: "index_labels_on_title", using: :btree - add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree create_table "lfs_objects", force: :cascade do |t| t.string "oid", null: false -- cgit v1.2.3 From 8a9bc24ef87739580c19ee8455bd8224d3c18b3e Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Tue, 28 Feb 2017 11:12:11 +0100 Subject: align schema.rb with upstream and fix rubocop warning about not freezing mutable constants and empty error classes --- db/schema.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index be54b177fa6..3898eed81bd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -111,10 +111,11 @@ ActiveRecord::Schema.define(version: 20170305203726) do 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.string "default_artifacts_expire_in", default: '0', null: false t.integer "unique_ips_limit_per_user", default: 10, null: false t.integer "unique_ips_limit_time_window", default: 3600, null: false t.boolean "unique_ips_limit_enabled", default: false, null: false + t.string "default_artifacts_expire_in", default: "0", null: false end create_table "audit_events", force: :cascade do |t| @@ -255,8 +256,8 @@ ActiveRecord::Schema.define(version: 20170305203726) do t.integer "lock_version" end + add_index "ci_commits", ["gl_project_id", "ref", "status"], name: "index_ci_commits_on_gl_project_id_and_ref_and_status", using: :btree add_index "ci_commits", ["gl_project_id", "sha"], name: "index_ci_commits_on_gl_project_id_and_sha", using: :btree - add_index "ci_commits", ["gl_project_id", "status"], name: "index_ci_commits_on_gl_project_id_and_status", using: :btree add_index "ci_commits", ["gl_project_id"], name: "index_ci_commits_on_gl_project_id", using: :btree add_index "ci_commits", ["status"], name: "index_ci_commits_on_status", using: :btree add_index "ci_commits", ["user_id"], name: "index_ci_commits_on_user_id", using: :btree -- cgit v1.2.3 From 70b9d8da4c24bc2317220bedb81b5d2ecf34c351 Mon Sep 17 00:00:00 2001 From: Pawel Chojnacki Date: Fri, 3 Mar 2017 18:10:22 +0100 Subject: Remove unecessary defaults for uniq ip block, cleanup refactoring leftovers --- ...0170210131347_add_unique_ips_limit_to_application_settings.rb | 4 ++-- db/schema.rb | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb b/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb index cbcf9a30b3c..9ab970134be 100644 --- a/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb +++ b/db/migrate/20170210131347_add_unique_ips_limit_to_application_settings.rb @@ -4,8 +4,8 @@ class AddUniqueIpsLimitToApplicationSettings < ActiveRecord::Migration disable_ddl_transaction! def up - add_column_with_default :application_settings, :unique_ips_limit_per_user, :integer, default: 10 - add_column_with_default :application_settings, :unique_ips_limit_time_window, :integer, default: 3600 + add_column :application_settings, :unique_ips_limit_per_user, :integer + add_column :application_settings, :unique_ips_limit_time_window, :integer add_column_with_default :application_settings, :unique_ips_limit_enabled, :boolean, default: false end diff --git a/db/schema.rb b/db/schema.rb index 3898eed81bd..911cb22c8e5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -111,11 +111,10 @@ ActiveRecord::Schema.define(version: 20170305203726) do 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", default: 10, null: false - t.integer "unique_ips_limit_time_window", default: 3600, null: false - t.boolean "unique_ips_limit_enabled", default: false, 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 end create_table "audit_events", force: :cascade do |t| @@ -587,9 +586,9 @@ ActiveRecord::Schema.define(version: 20170305203726) do end add_index "labels", ["group_id", "project_id", "title"], name: "index_labels_on_group_id_and_project_id_and_title", unique: true, using: :btree - add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree add_index "labels", ["title"], name: "index_labels_on_title", using: :btree + add_index "labels", ["type", "project_id"], name: "index_labels_on_type_and_project_id", using: :btree create_table "lfs_objects", force: :cascade do |t| t.string "oid", null: false -- cgit v1.2.3 From 3b35d1f8c153fb31af66049ba5461f9b39c66397 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 6 Mar 2017 18:24:55 +0100 Subject: Migrate legacy actions in post deployment migration --- .../20170306090835_migrate_legacy_manual_actions.rb | 19 ------------------- .../20170306170512_migrate_legacy_manual_actions.rb | 19 +++++++++++++++++++ db/schema.rb | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 db/migrate/20170306090835_migrate_legacy_manual_actions.rb create mode 100644 db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb (limited to 'db') diff --git a/db/migrate/20170306090835_migrate_legacy_manual_actions.rb b/db/migrate/20170306090835_migrate_legacy_manual_actions.rb deleted file mode 100644 index 9020e0d054c..00000000000 --- a/db/migrate/20170306090835_migrate_legacy_manual_actions.rb +++ /dev/null @@ -1,19 +0,0 @@ -class MigrateLegacyManualActions < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def up - execute <<-EOS - UPDATE ci_builds SET status = 'manual', allow_failure = true - WHERE ci_builds.when = 'manual' AND ci_builds.status = 'skipped'; - EOS - end - - def down - execute <<-EOS - UPDATE ci_builds SET status = 'skipped', allow_failure = false - WHERE ci_builds.when = 'manual' AND ci_builds.status = 'manual'; - EOS - end -end diff --git a/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb b/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb new file mode 100644 index 00000000000..9020e0d054c --- /dev/null +++ b/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb @@ -0,0 +1,19 @@ +class MigrateLegacyManualActions < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + execute <<-EOS + UPDATE ci_builds SET status = 'manual', allow_failure = true + WHERE ci_builds.when = 'manual' AND ci_builds.status = 'skipped'; + EOS + end + + def down + execute <<-EOS + UPDATE ci_builds SET status = 'skipped', allow_failure = false + WHERE ci_builds.when = 'manual' AND ci_builds.status = 'manual'; + EOS + end +end diff --git a/db/schema.rb b/db/schema.rb index d1d3f9d6dd5..68e755979ff 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: 20170306090835) do +ActiveRecord::Schema.define(version: 20170306170512) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 005749a616c19b90d6ec0415df9ae5e35151e33c Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Wed, 1 Mar 2017 16:59:03 +0000 Subject: apply codestyle and implementation changes to the respective feature code --- .../20161228135550_add_impersonation_to_personal_access_tokens.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb b/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb index 48648043dbb..ea9caceaa2c 100644 --- a/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb +++ b/db/migrate/20161228135550_add_impersonation_to_personal_access_tokens.rb @@ -9,7 +9,7 @@ class AddImpersonationToPersonalAccessTokens < ActiveRecord::Migration DOWNTIME = false def up - add_column_with_default :personal_access_tokens, :impersonation, :boolean, default: false, null: false + add_column_with_default :personal_access_tokens, :impersonation, :boolean, default: false, allow_null: false end def down -- cgit v1.2.3 From 4c622b71fd284058deee483bf0009f8179b792bc Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 22 Feb 2017 14:25:06 -0500 Subject: Add Upload model and UploadChecksumWorker worker --- db/migrate/20170130221926_create_uploads.rb | 20 ++++++++++++++++++++ db/schema.rb | 14 ++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 db/migrate/20170130221926_create_uploads.rb (limited to 'db') diff --git a/db/migrate/20170130221926_create_uploads.rb b/db/migrate/20170130221926_create_uploads.rb new file mode 100644 index 00000000000..6f06c5dd840 --- /dev/null +++ b/db/migrate/20170130221926_create_uploads.rb @@ -0,0 +1,20 @@ +class CreateUploads < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :uploads do |t| + t.integer :size, limit: 8, null: false + t.string :path, null: false + t.string :checksum, limit: 64 + t.references :model, polymorphic: true + t.string :uploader, null: false + t.datetime :created_at, null: false + end + + add_index :uploads, :path + add_index :uploads, :checksum + add_index :uploads, [:model_id, :model_type] + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f7dd3e4768..9f31ee8e6c5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1214,6 +1214,20 @@ ActiveRecord::Schema.define(version: 20170306170512) do add_index "u2f_registrations", ["key_handle"], name: "index_u2f_registrations_on_key_handle", using: :btree add_index "u2f_registrations", ["user_id"], name: "index_u2f_registrations_on_user_id", using: :btree + create_table "uploads", force: :cascade do |t| + t.integer "size", limit: 8, null: false + t.string "path", null: false + t.string "checksum", limit: 64 + t.integer "model_id" + t.string "model_type" + t.string "uploader", null: false + t.datetime "created_at", null: false + end + + add_index "uploads", ["checksum"], name: "index_uploads_on_checksum", using: :btree + add_index "uploads", ["model_id", "model_type"], name: "index_uploads_on_model_id_and_model_type", using: :btree + add_index "uploads", ["path"], name: "index_uploads_on_path", using: :btree + create_table "user_agent_details", force: :cascade do |t| t.string "user_agent", null: false t.string "ip_address", null: false -- cgit v1.2.3 From 96cbad23378e492f2564a8ec4121b7b3548a7df3 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Mon, 6 Mar 2017 11:59:26 -0600 Subject: Fix up @DouweM review --- db/fixtures/development/15_award_emoji.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/fixtures/development/15_award_emoji.rb b/db/fixtures/development/15_award_emoji.rb index ea343c26b69..137a036edaf 100644 --- a/db/fixtures/development/15_award_emoji.rb +++ b/db/fixtures/development/15_award_emoji.rb @@ -1,7 +1,7 @@ require './spec/support/sidekiq' Gitlab::Seeder.quiet do - emoji = Gitlab::AwardEmoji.emojis.keys + emoji = Gitlab::Emoji.emojis.keys Issue.order(Gitlab::Database.random).limit(Issue.count / 2).each do |issue| project = issue.project -- cgit v1.2.3 From 1497db75f5f4850f51082de326fa0b4d8574bf3b Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 7 Mar 2017 15:29:30 +0200 Subject: Fix AddRelativePositionToIssues migration --- db/migrate/20170131221752_add_relative_position_to_issues.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170131221752_add_relative_position_to_issues.rb b/db/migrate/20170131221752_add_relative_position_to_issues.rb index 28c3d1012ce..1baad0893e3 100644 --- a/db/migrate/20170131221752_add_relative_position_to_issues.rb +++ b/db/migrate/20170131221752_add_relative_position_to_issues.rb @@ -21,11 +21,17 @@ class AddRelativePositionToIssues < ActiveRecord::Migration # # To disable transactions uncomment the following line and remove these # comments: - # disable_ddl_transaction! + disable_ddl_transaction! - def change + def up add_column :issues, :relative_position, :integer add_concurrent_index :issues, :relative_position end + + def down + remove_column :issues, :relative_position + + remove_index :issues, :relative_position if index_exists? :issues, :relative_position + end end -- cgit v1.2.3 From c4982890489d254da2fe998aab30bf257767ed5e Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Fri, 9 Dec 2016 18:36:50 +0100 Subject: Implement OpenID Connect identity provider --- ...5216_create_doorkeeper_openid_connect_tables.rb | 37 ++++++++++++++++++++++ ...lidate_foreign_keys_on_oauth_openid_requests.rb | 20 ++++++++++++ db/schema.rb | 6 ++++ 3 files changed, 63 insertions(+) create mode 100644 db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb create mode 100644 db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb (limited to 'db') diff --git a/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb b/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb new file mode 100644 index 00000000000..e63d5927f86 --- /dev/null +++ b/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb @@ -0,0 +1,37 @@ +class CreateDoorkeeperOpenidConnectTables < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + create_table :oauth_openid_requests do |t| + t.integer :access_grant_id, null: false + t.string :nonce, null: false + end + + if Gitlab::Database.postgresql? + # add foreign key without validation to avoid downtime on PostgreSQL, + # also see db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb + execute %q{ + ALTER TABLE "oauth_openid_requests" + ADD CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id" + FOREIGN KEY ("access_grant_id") + REFERENCES "oauth_access_grants" ("id") + NOT VALID; + } + else + execute %q{ + ALTER TABLE oauth_openid_requests + ADD CONSTRAINT fk_oauth_openid_requests_oauth_access_grants_access_grant_id + FOREIGN KEY (access_grant_id) + REFERENCES oauth_access_grants (id); + } + end + end + + def down + drop_table :oauth_openid_requests + end +end diff --git a/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb b/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb new file mode 100644 index 00000000000..e206f9af636 --- /dev/null +++ b/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb @@ -0,0 +1,20 @@ +class ValidateForeignKeysOnOauthOpenidRequests < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + if Gitlab::Database.postgresql? + execute %q{ + ALTER TABLE "oauth_openid_requests" + VALIDATE CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id"; + } + end + end + + def down + # noop + end +end diff --git a/db/schema.rb b/db/schema.rb index 624cf9432d0..8984ab3aac1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -878,6 +878,11 @@ ActiveRecord::Schema.define(version: 20170306170512) do add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree + create_table "oauth_openid_requests", force: :cascade do |t| + t.integer "access_grant_id", null: false + t.string "nonce", null: false + end + create_table "pages_domains", force: :cascade do |t| t.integer "project_id" t.text "certificate" @@ -1374,6 +1379,7 @@ ActiveRecord::Schema.define(version: 20170306170512) do add_foreign_key "merge_request_metrics", "merge_requests", on_delete: :cascade add_foreign_key "merge_requests_closing_issues", "issues", on_delete: :cascade add_foreign_key "merge_requests_closing_issues", "merge_requests", on_delete: :cascade + add_foreign_key "oauth_openid_requests", "oauth_access_grants", column: "access_grant_id", name: "fk_oauth_openid_requests_oauth_access_grants_access_grant_id" add_foreign_key "personal_access_tokens", "users" add_foreign_key "project_authorizations", "projects", on_delete: :cascade add_foreign_key "project_authorizations", "users", on_delete: :cascade -- cgit v1.2.3 From 9c25404ac0d0d960524cc8fd731ff205ba96e663 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Tue, 7 Mar 2017 10:06:53 +0100 Subject: Rename BUILD to JOB in CI Variables Given GitLab moves away from using the term build, everywhere, also the CI variables are being renamed. For now, both `CI_BUILD_X` and `CI_JOB_X` are supported, with the same values. However, in about 3 months, support will be dropped. --- db/schema.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 624cf9432d0..d66ae7fb6b7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,6 +61,7 @@ ActiveRecord::Schema.define(version: 20170306170512) 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 @@ -109,7 +110,6 @@ ActiveRecord::Schema.define(version: 20170306170512) 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" @@ -771,8 +771,8 @@ ActiveRecord::Schema.define(version: 20170306170512) 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" end -- cgit v1.2.3 From 5d9762b3b5ace3da397b83f501d103a5152f0dd3 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 7 Mar 2017 10:08:53 -0600 Subject: Add cop to ensure reversibility of add_concurrent_index --- .../20160615142710_add_index_on_requested_at_to_members.rb | 6 +++++- db/migrate/20160620115026_add_index_on_runners_locked.rb | 6 +++++- db/migrate/20160715134306_add_index_for_pipeline_user_id.rb | 6 +++++- db/migrate/20160805041956_add_deleted_at_to_namespaces.rb | 9 ++++++++- db/migrate/20160808085602_add_index_for_build_token.rb | 6 +++++- db/migrate/20160819221631_add_index_to_note_discussion_id.rb | 6 +++++- db/migrate/20160819232256_add_incoming_email_token_to_users.rb | 9 ++++++++- db/migrate/20160919145149_add_group_id_to_labels.rb | 8 +++++++- db/migrate/20160920160832_add_index_to_labels_title.rb | 6 +++++- .../20161020083353_add_pipeline_id_to_merge_request_metrics.rb | 10 ++++++++-- .../20161106185620_add_project_import_data_project_index.rb | 6 +++++- db/migrate/20161124111395_add_index_to_parent_id.rb | 6 +++++- db/migrate/20161202152035_add_index_to_routes.rb | 7 ++++++- .../20161209153400_add_unique_index_for_environment_slug.rb | 6 +++++- .../20170204181513_add_index_to_labels_for_type_and_project.rb | 6 +++++- ...20170210062829_add_index_to_labels_for_title_and_project.rb | 7 ++++++- ...210075922_add_index_to_ci_trigger_requests_for_commit_id.rb | 6 +++++- db/migrate/20170210103609_add_index_to_user_agent_detail.rb | 8 ++++++-- .../20170216135621_add_index_for_latest_successful_pipeline.rb | 8 ++++++-- 19 files changed, 110 insertions(+), 22 deletions(-) (limited to 'db') diff --git a/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb b/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb index 63f7392e54f..e23b33f78d8 100644 --- a/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb +++ b/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb @@ -3,7 +3,11 @@ class AddIndexOnRequestedAtToMembers < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :members, :requested_at end + + def down + remove_index :members, :requested_at if index_exists? :members, :requested_at + end end diff --git a/db/migrate/20160620115026_add_index_on_runners_locked.rb b/db/migrate/20160620115026_add_index_on_runners_locked.rb index dfa5110dea4..62b00cc3e2c 100644 --- a/db/migrate/20160620115026_add_index_on_runners_locked.rb +++ b/db/migrate/20160620115026_add_index_on_runners_locked.rb @@ -6,7 +6,11 @@ class AddIndexOnRunnersLocked < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :ci_runners, :locked end + + def down + remove_index :ci_runners, :locked if index_exists? :ci_runners, :locked + end end diff --git a/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb b/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb index 7c991c6d998..12fd25b420d 100644 --- a/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb +++ b/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb @@ -3,7 +3,11 @@ class AddIndexForPipelineUserId < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :ci_commits, :user_id end + + def down + remove_index :ci_commits, :user_id if index_exists? :ci_commits, :user_id + end end diff --git a/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb b/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb index a853de3abfb..3f074723b4a 100644 --- a/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb +++ b/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb @@ -5,8 +5,15 @@ class AddDeletedAtToNamespaces < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_column :namespaces, :deleted_at, :datetime + add_concurrent_index :namespaces, :deleted_at end + + def down + remove_index :namespaces, :deleted_at if index_exists? :namespaces, :deleted_at + + remove_column :namespaces, :deleted_at + end end diff --git a/db/migrate/20160808085602_add_index_for_build_token.rb b/db/migrate/20160808085602_add_index_for_build_token.rb index 10ef42afce1..6c5d7268e72 100644 --- a/db/migrate/20160808085602_add_index_for_build_token.rb +++ b/db/migrate/20160808085602_add_index_for_build_token.rb @@ -6,7 +6,11 @@ class AddIndexForBuildToken < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :ci_builds, :token, unique: true end + + def down + remove_index :ci_builds, :token, unique: true if index_exists? :ci_builds, :token, unique: true + end end diff --git a/db/migrate/20160819221631_add_index_to_note_discussion_id.rb b/db/migrate/20160819221631_add_index_to_note_discussion_id.rb index b6e8bb18e7b..8f693e97a58 100644 --- a/db/migrate/20160819221631_add_index_to_note_discussion_id.rb +++ b/db/migrate/20160819221631_add_index_to_note_discussion_id.rb @@ -8,7 +8,11 @@ class AddIndexToNoteDiscussionId < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :notes, :discussion_id end + + def down + remove_index :notes, :discussion_id if index_exists? :notes, :discussion_id + end end diff --git a/db/migrate/20160819232256_add_incoming_email_token_to_users.rb b/db/migrate/20160819232256_add_incoming_email_token_to_users.rb index f2cf956adc9..bcad3416d04 100644 --- a/db/migrate/20160819232256_add_incoming_email_token_to_users.rb +++ b/db/migrate/20160819232256_add_incoming_email_token_to_users.rb @@ -9,8 +9,15 @@ class AddIncomingEmailTokenToUsers < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_column :users, :incoming_email_token, :string + add_concurrent_index :users, :incoming_email_token end + + def down + remove_index :users, :incoming_email_token if index_exists? :users, :incoming_email_token + + remove_column :users, :incoming_email_token + end end diff --git a/db/migrate/20160919145149_add_group_id_to_labels.rb b/db/migrate/20160919145149_add_group_id_to_labels.rb index d10f3a6d104..828b6afddb1 100644 --- a/db/migrate/20160919145149_add_group_id_to_labels.rb +++ b/db/migrate/20160919145149_add_group_id_to_labels.rb @@ -5,9 +5,15 @@ class AddGroupIdToLabels < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_column :labels, :group_id, :integer add_foreign_key :labels, :namespaces, column: :group_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey add_concurrent_index :labels, :group_id end + + def down + remove_index :labels, :group_id if index_exists? :labels, :group_id + remove_foreign_key :labels, :namespaces, column: :group_id + remove_column :labels, :group_id + end end diff --git a/db/migrate/20160920160832_add_index_to_labels_title.rb b/db/migrate/20160920160832_add_index_to_labels_title.rb index b5de552b98c..19f7b1076a7 100644 --- a/db/migrate/20160920160832_add_index_to_labels_title.rb +++ b/db/migrate/20160920160832_add_index_to_labels_title.rb @@ -5,7 +5,11 @@ class AddIndexToLabelsTitle < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :labels, :title end + + def down + remove_index :labels, :title if index_exists? :labels, :title + end end diff --git a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb index 2abfe47b776..ad3eb4a26f9 100644 --- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb +++ b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb @@ -25,9 +25,15 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration # comments: # disable_ddl_transaction! - def change + def up add_column :merge_request_metrics, :pipeline_id, :integer - add_concurrent_index :merge_request_metrics, :pipeline_id add_foreign_key :merge_request_metrics, :ci_commits, column: :pipeline_id, on_delete: :cascade # rubocop: disable Migration/AddConcurrentForeignKey + add_concurrent_index :merge_request_metrics, :pipeline_id + end + + def down + remove_index :merge_request_metrics, :pipeline_id if index_exists? :merge_request_metrics, :pipeline_id + remove_foreign_key :merge_request_metrics, :ci_commits, column: :pipeline_id + remove_column :merge_request_metrics, :pipeline_id end end diff --git a/db/migrate/20161106185620_add_project_import_data_project_index.rb b/db/migrate/20161106185620_add_project_import_data_project_index.rb index 750a6a8c51e..94b8ddd46f5 100644 --- a/db/migrate/20161106185620_add_project_import_data_project_index.rb +++ b/db/migrate/20161106185620_add_project_import_data_project_index.rb @@ -6,7 +6,11 @@ class AddProjectImportDataProjectIndex < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :project_import_data, :project_id end + + def down + remove_index :project_import_data, :project_id if index_exists? :project_import_data, :project_id + end end diff --git a/db/migrate/20161124111395_add_index_to_parent_id.rb b/db/migrate/20161124111395_add_index_to_parent_id.rb index eab74c01dfd..73f9d92bb22 100644 --- a/db/migrate/20161124111395_add_index_to_parent_id.rb +++ b/db/migrate/20161124111395_add_index_to_parent_id.rb @@ -8,7 +8,11 @@ class AddIndexToParentId < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index(:namespaces, [:parent_id, :id], unique: true) end + + def down + remove_index :namespaces, [:parent_id, :id] if index_exists? :namespaces, [:parent_id, :id] + end end diff --git a/db/migrate/20161202152035_add_index_to_routes.rb b/db/migrate/20161202152035_add_index_to_routes.rb index 4a51337bda6..6d6c8906204 100644 --- a/db/migrate/20161202152035_add_index_to_routes.rb +++ b/db/migrate/20161202152035_add_index_to_routes.rb @@ -9,8 +9,13 @@ class AddIndexToRoutes < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index(:routes, :path, unique: true) add_concurrent_index(:routes, [:source_type, :source_id], unique: true) end + + def down + remove_index(:routes, :path) if index_exists? :routes, :path + remove_index(:routes, [:source_type, :source_id]) if index_exists? :routes, [:source_type, :source_id] + end end diff --git a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb index e9fcef1cd45..d7ef1aa83d9 100644 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb @@ -9,7 +9,11 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :environments, [:project_id, :slug], unique: true end + + def down + remove_index :environments, [:project_id, :slug], unique: true if index_exists? :environments, [:project_id, :slug] + end end diff --git a/db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb b/db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb index 8f944930807..31ef458c44f 100644 --- a/db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb +++ b/db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb @@ -5,7 +5,11 @@ class AddIndexToLabelsForTypeAndProject < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :labels, [:type, :project_id] end + + def down + remove_index :labels, [:type, :project_id] if index_exists? :labels, [:type, :project_id] + end end diff --git a/db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb b/db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb index f922ed209aa..70fb0ef12f9 100644 --- a/db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb +++ b/db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb @@ -5,8 +5,13 @@ class AddIndexToLabelsForTitleAndProject < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :labels, :title add_concurrent_index :labels, :project_id end + + def down + remove_index :labels, :title if index_exists? :labels, :title + remove_index :labels, :project_id if index_exists? :labels, :project_id + end end diff --git a/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb b/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb index 61e49c14fc0..07d4f8af27f 100644 --- a/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb +++ b/db/migrate/20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb @@ -5,7 +5,11 @@ class AddIndexToCiTriggerRequestsForCommitId < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_index :ci_trigger_requests, :commit_id end + + def down + remove_index :ci_trigger_requests, :commit_id if index_exists? :ci_trigger_requests, :commit_id + end end diff --git a/db/migrate/20170210103609_add_index_to_user_agent_detail.rb b/db/migrate/20170210103609_add_index_to_user_agent_detail.rb index c01753cfbd2..2d8329b7862 100644 --- a/db/migrate/20170210103609_add_index_to_user_agent_detail.rb +++ b/db/migrate/20170210103609_add_index_to_user_agent_detail.rb @@ -8,7 +8,11 @@ class AddIndexToUserAgentDetail < ActiveRecord::Migration disable_ddl_transaction! - def change - add_concurrent_index(:user_agent_details, [:subject_id, :subject_type]) + def up + add_concurrent_index :user_agent_details, [:subject_id, :subject_type] + end + + def down + remove_index :user_agent_details, [:subject_id, :subject_type] if index_exists? :user_agent_details, [:subject_id, :subject_type] end end diff --git a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb index 7b1e687977b..65adc90c2c1 100644 --- a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb +++ b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb @@ -4,7 +4,11 @@ class AddIndexForLatestSuccessfulPipeline < ActiveRecord::Migration disable_ddl_transaction! - def change - add_concurrent_index(:ci_commits, [:gl_project_id, :ref, :status]) + def up + add_concurrent_index :ci_commits, [:gl_project_id, :ref, :status] + end + + def down + remove_index :ci_commits, [:gl_project_id, :ref, :status] if index_exists? :ci_commits, [:gl_project_id, :ref, :status] end end -- cgit v1.2.3 From e3ddd871027e2e9f4ceef658a5ba646d5ade7045 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 7 Mar 2017 12:14:31 -0600 Subject: Add downtime constants --- db/migrate/20160615142710_add_index_on_requested_at_to_members.rb | 2 ++ db/migrate/20160620115026_add_index_on_runners_locked.rb | 2 ++ db/migrate/20160715134306_add_index_for_pipeline_user_id.rb | 2 ++ 3 files changed, 6 insertions(+) (limited to 'db') diff --git a/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb b/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb index e23b33f78d8..7a8ed99c68f 100644 --- a/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb +++ b/db/migrate/20160615142710_add_index_on_requested_at_to_members.rb @@ -1,6 +1,8 @@ class AddIndexOnRequestedAtToMembers < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers + DOWNTIME = false + disable_ddl_transaction! def up diff --git a/db/migrate/20160620115026_add_index_on_runners_locked.rb b/db/migrate/20160620115026_add_index_on_runners_locked.rb index 62b00cc3e2c..6ca486c63d1 100644 --- a/db/migrate/20160620115026_add_index_on_runners_locked.rb +++ b/db/migrate/20160620115026_add_index_on_runners_locked.rb @@ -4,6 +4,8 @@ class AddIndexOnRunnersLocked < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers + DOWNTIME = false + disable_ddl_transaction! def up diff --git a/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb b/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb index 12fd25b420d..a05a4c679e3 100644 --- a/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb +++ b/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb @@ -1,6 +1,8 @@ class AddIndexForPipelineUserId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers + DOWNTIME = false + disable_ddl_transaction! def up -- cgit v1.2.3 From dbf414df33160b8ca15650c56bab9e9b3f2d0ccf Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 31 Jan 2017 22:44:31 +0100 Subject: Trigger refreshing of permissions in a migration This migration resets `users.authorized_projects_populated` (in batches) so that active users' permissions are refreshed on the next request. This ensures that their permissions are properly stored. --- ...14021_reset_users_authorized_projects_populated.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb (limited to 'db') diff --git a/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb b/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb new file mode 100644 index 00000000000..b518038e93a --- /dev/null +++ b/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb @@ -0,0 +1,19 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class ResetUsersAuthorizedProjectsPopulated < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + # This ensures we don't lock all users for the duration of the migration. + update_column_in_batches(:users, :authorized_projects_populated, nil) + end + + def down + # noop + end +end -- cgit v1.2.3 From cd4db7b4171a090d25391f4cf0425ece3692fa9f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 13 Mar 2017 15:39:41 +0200 Subject: Reserve few project and nested group paths That have wildcard routes associated and not reserved yet: artifacts, graphs, badges and refs Signed-off-by: Dmitriy Zaporozhets --- ...313133418_rename_more_reserved_project_names.rb | 101 +++++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 db/post_migrate/20170313133418_rename_more_reserved_project_names.rb (limited to 'db') diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb new file mode 100644 index 00000000000..9dfe77bedb7 --- /dev/null +++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb @@ -0,0 +1,101 @@ +require 'thread' + +class RenameMoreReservedProjectNames < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + include Gitlab::ShellAdapter + + DOWNTIME = false + + THREAD_COUNT = 8 + + KNOWN_PATHS = %w(artifacts graphs refs badges).freeze + + def up + queues = Array.new(THREAD_COUNT) { Queue.new } + start = false + + threads = Array.new(THREAD_COUNT) do |index| + Thread.new do + queue = queues[index] + + # Wait until we have input to process. + until start; end + + rename_projects(queue.pop) until queue.empty? + end + end + + enum = queues.each + + reserved_projects.each_slice(100) do |slice| + begin + queue = enum.next + rescue StopIteration + enum.rewind + retry + end + + queue << slice + end + + start = true + + threads.each(&:join) + 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) + + ActiveRecord::Base.connection. + select_all("SELECT id, path FROM routes WHERE 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/schema.rb b/db/schema.rb index 3ec5461f600..ca88198079f 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: 20170306170512) do +ActiveRecord::Schema.define(version: 20170313133418) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 67729cecc12a56591160d04ea5d79614b1102dc6 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 13 Mar 2017 20:36:17 +0800 Subject: Add a test which would rollback db and migrate again Closes #29106 --- db/migrate/20160919145149_add_group_id_to_labels.rb | 2 +- .../20161020083353_add_pipeline_id_to_merge_request_metrics.rb | 2 +- db/migrate/20161031171301_add_project_id_to_subscriptions.rb | 1 + .../20161207231621_create_environment_name_unique_index.rb | 4 ++-- .../20161209153400_add_unique_index_for_environment_slug.rb | 2 +- db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb | 10 ++++++++++ .../20170216141440_drop_index_for_builds_project_status.rb | 2 +- .../20170206101007_remove_trackable_columns_from_timelogs.rb | 3 ++- 8 files changed, 19 insertions(+), 7 deletions(-) (limited to 'db') diff --git a/db/migrate/20160919145149_add_group_id_to_labels.rb b/db/migrate/20160919145149_add_group_id_to_labels.rb index 828b6afddb1..e20e693f3aa 100644 --- a/db/migrate/20160919145149_add_group_id_to_labels.rb +++ b/db/migrate/20160919145149_add_group_id_to_labels.rb @@ -12,8 +12,8 @@ class AddGroupIdToLabels < ActiveRecord::Migration end def down + remove_foreign_key :labels, column: :group_id remove_index :labels, :group_id if index_exists? :labels, :group_id - remove_foreign_key :labels, :namespaces, column: :group_id remove_column :labels, :group_id end end diff --git a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb index ad3eb4a26f9..35ad22b6c01 100644 --- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb +++ b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb @@ -32,8 +32,8 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration end def down + remove_foreign_key :merge_request_metrics, column: :pipeline_id remove_index :merge_request_metrics, :pipeline_id if index_exists? :merge_request_metrics, :pipeline_id - remove_foreign_key :merge_request_metrics, :ci_commits, column: :pipeline_id remove_column :merge_request_metrics, :pipeline_id end end diff --git a/db/migrate/20161031171301_add_project_id_to_subscriptions.rb b/db/migrate/20161031171301_add_project_id_to_subscriptions.rb index d5c343dc527..8b1c10a124f 100644 --- a/db/migrate/20161031171301_add_project_id_to_subscriptions.rb +++ b/db/migrate/20161031171301_add_project_id_to_subscriptions.rb @@ -9,6 +9,7 @@ class AddProjectIdToSubscriptions < ActiveRecord::Migration end def down + remove_foreign_key :subscriptions, column: :project_id remove_column :subscriptions, :project_id end end diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb index ac680c8d10f..5ff0f5bae4d 100644 --- a/db/migrate/20161207231621_create_environment_name_unique_index.rb +++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb @@ -12,7 +12,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration end def down - remove_index :environments, [:project_id, :name], unique: true - add_concurrent_index :environments, [:project_id, :name] + remove_index :environments, [:project_id, :name] + add_concurrent_index :environments, [:project_id, :name], unique: true end end diff --git a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb index d7ef1aa83d9..ede0316e860 100644 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb @@ -14,6 +14,6 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration end def down - remove_index :environments, [:project_id, :slug], unique: true if index_exists? :environments, [:project_id, :slug] + remove_index :environments, [:project_id, :slug] if index_exists? :environments, [:project_id, :slug] end end diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb index 69bfa2d3fc4..676e18cddd3 100644 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb @@ -49,6 +49,16 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration Timelog.where('issue_id IS NOT NULL').update_all("trackable_id = issue_id, trackable_type = 'Issue'") Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'") + constraint = + if Gitlab::Database.postgresql? + 'CONSTRAINT' + else + 'FOREIGN KEY' + end + + execute "ALTER TABLE timelogs DROP #{constraint} fk_timelogs_issues_issue_id" + execute "ALTER TABLE timelogs DROP #{constraint} fk_timelogs_merge_requests_merge_request_id" + remove_columns :timelogs, :issue_id, :merge_request_id end end diff --git a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb index 906711b9f3f..a2839f52d89 100644 --- a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb +++ b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb @@ -3,6 +3,6 @@ class DropIndexForBuildsProjectStatus < ActiveRecord::Migration DOWNTIME = false def change - remove_index(:ci_commits, [:gl_project_id, :status]) + remove_index(:ci_commits, column: [:gl_project_id, :status]) end end diff --git a/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb b/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb index 89aa753646c..aee0c1b6245 100644 --- a/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb +++ b/db/post_migrate/20170206101007_remove_trackable_columns_from_timelogs.rb @@ -18,6 +18,7 @@ class RemoveTrackableColumnsFromTimelogs < ActiveRecord::Migration # disable_ddl_transaction! def change - remove_columns :timelogs, :trackable_id, :trackable_type + remove_column :timelogs, :trackable_id, :integer + remove_column :timelogs, :trackable_type, :string end end -- cgit v1.2.3 From 0b20d850cb964da89f8b0df3c9e78a1cc2a86e1b Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 14 Mar 2017 14:36:33 +0800 Subject: Fix for postgresql --- db/migrate/20161201160452_migrate_project_statistics.rb | 4 ++-- db/migrate/20161212142807_add_lower_path_index_to_routes.rb | 2 +- db/migrate/20170130204620_add_index_to_project_authorizations.rb | 4 ++++ db/migrate/20170305203726_add_owner_id_foreign_key.rb | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb index 3ae3f2c159b..8386f7f9d4f 100644 --- a/db/migrate/20161201160452_migrate_project_statistics.rb +++ b/db/migrate/20161201160452_migrate_project_statistics.rb @@ -17,7 +17,7 @@ class MigrateProjectStatistics < ActiveRecord::Migration end def down - add_column_with_default :projects, :repository_size, :float, default: 0.0 - add_column_with_default :projects, :commit_count, :integer, default: 0 + add_column :projects, :repository_size, :float, default: 0.0 + add_column :projects, :commit_count, :integer, default: 0 end end diff --git a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb index 6958500306f..53f4c6bbb18 100644 --- a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb +++ b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb @@ -17,6 +17,6 @@ class AddLowerPathIndexToRoutes < ActiveRecord::Migration def down return unless Gitlab::Database.postgresql? - remove_index :routes, name: :index_on_routes_lower_path + remove_index :routes, name: :index_on_routes_lower_path if index_exists?(:routes, name: :index_on_routes_lower_path) end end diff --git a/db/migrate/20170130204620_add_index_to_project_authorizations.rb b/db/migrate/20170130204620_add_index_to_project_authorizations.rb index e9a0aee4d6a..a8c504f265a 100644 --- a/db/migrate/20170130204620_add_index_to_project_authorizations.rb +++ b/db/migrate/20170130204620_add_index_to_project_authorizations.rb @@ -8,4 +8,8 @@ class AddIndexToProjectAuthorizations < ActiveRecord::Migration def up add_concurrent_index(:project_authorizations, :project_id) end + + def down + remove_index(:project_authorizations, :project_id) + end end diff --git a/db/migrate/20170305203726_add_owner_id_foreign_key.rb b/db/migrate/20170305203726_add_owner_id_foreign_key.rb index 3eece0e2eb5..5fbdc45f1a7 100644 --- a/db/migrate/20170305203726_add_owner_id_foreign_key.rb +++ b/db/migrate/20170305203726_add_owner_id_foreign_key.rb @@ -5,7 +5,11 @@ class AddOwnerIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade end + + def down + remove_foreign_key :ci_triggers, column: :owner_id + end end -- cgit v1.2.3 From c9fbbb3ae2c7f0eb44b0f973155d68e678149544 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 14 Mar 2017 19:56:37 +0800 Subject: Disable rubocop for down method --- db/migrate/20161201160452_migrate_project_statistics.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'db') diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb index 8386f7f9d4f..82fbdf02444 100644 --- a/db/migrate/20161201160452_migrate_project_statistics.rb +++ b/db/migrate/20161201160452_migrate_project_statistics.rb @@ -16,6 +16,7 @@ class MigrateProjectStatistics < ActiveRecord::Migration remove_column :projects, :commit_count end + # rubocop: disable Migration/AddColumn def down add_column :projects, :repository_size, :float, default: 0.0 add_column :projects, :commit_count, :integer, default: 0 -- cgit v1.2.3 From f67d8eb1da269150764224cea1807195cdf2ffb5 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 14 Mar 2017 20:03:22 +0800 Subject: Drop the index only for postgresql, because mysql cannot simply drop the index without dropping the corresponding foreign key, and we certainly don't want to drop the foreign key here. --- db/migrate/20170130204620_add_index_to_project_authorizations.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170130204620_add_index_to_project_authorizations.rb b/db/migrate/20170130204620_add_index_to_project_authorizations.rb index a8c504f265a..629b49436e3 100644 --- a/db/migrate/20170130204620_add_index_to_project_authorizations.rb +++ b/db/migrate/20170130204620_add_index_to_project_authorizations.rb @@ -10,6 +10,7 @@ class AddIndexToProjectAuthorizations < ActiveRecord::Migration end def down - remove_index(:project_authorizations, :project_id) + remove_index(:project_authorizations, :project_id) if + Gitlab::Database.postgresql? end end -- cgit v1.2.3 From 67686e38fdb1d9c427a39ff1862af691ccd4e598 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Thu, 9 Mar 2017 19:23:36 +0200 Subject: Added migration to reset existing relative_position for issues --- ...20170309171644_reset_relative_position_for_issue.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/post_migrate/20170309171644_reset_relative_position_for_issue.rb (limited to 'db') diff --git a/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb b/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb new file mode 100644 index 00000000000..ce4be131d40 --- /dev/null +++ b/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class ResetRelativePositionForIssue < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + execute <<-EOS + UPDATE issues SET relative_position = NULL + WHERE issues.relative_position IS NOT NULL; + EOS + end + + def down + end +end -- cgit v1.2.3 From b84723ac8bf8572c3d261980ab053dda52bc78dd Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 10 Mar 2017 17:17:55 +0200 Subject: [Issue Sorting] Improve migration --- .../20170309171644_reset_relative_position_for_issue.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb b/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb index ce4be131d40..b61dd7cfc61 100644 --- a/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb +++ b/db/post_migrate/20170309171644_reset_relative_position_for_issue.rb @@ -7,10 +7,9 @@ class ResetRelativePositionForIssue < ActiveRecord::Migration DOWNTIME = false def up - execute <<-EOS - UPDATE issues SET relative_position = NULL - WHERE issues.relative_position IS NOT NULL; - EOS + update_column_in_batches(:issues, :relative_position, nil) do |table, query| + query.where(table[:relative_position].not_eq(nil)) + end end def down -- cgit v1.2.3 From af8cc2e064bb97a8a1801521735d5403b189bfb5 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 14 Mar 2017 20:13:36 +0800 Subject: Use `remove_foreign_key :timelogs, name: '...'` Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9908#note_25324225 --- db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'db') diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb index 676e18cddd3..a7d4e141a1a 100644 --- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb +++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb @@ -49,15 +49,8 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration Timelog.where('issue_id IS NOT NULL').update_all("trackable_id = issue_id, trackable_type = 'Issue'") Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'") - constraint = - if Gitlab::Database.postgresql? - 'CONSTRAINT' - else - 'FOREIGN KEY' - end - - execute "ALTER TABLE timelogs DROP #{constraint} fk_timelogs_issues_issue_id" - execute "ALTER TABLE timelogs DROP #{constraint} fk_timelogs_merge_requests_merge_request_id" + remove_foreign_key :timelogs, name: 'fk_timelogs_issues_issue_id' + remove_foreign_key :timelogs, name: 'fk_timelogs_merge_requests_merge_request_id' remove_columns :timelogs, :issue_id, :merge_request_id end -- cgit v1.2.3 From fbbaff4a7141fbecca08e087f923c700290a6a74 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Tue, 14 Mar 2017 19:06:54 -0700 Subject: Fixing two migrations that could not be rolled back when rolling back from 9-0-stable to 8.17.3 --- db/migrate/20170216141440_drop_index_for_builds_project_status.rb | 2 +- db/migrate/20170305203726_add_owner_id_foreign_key.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb index 906711b9f3f..a2839f52d89 100644 --- a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb +++ b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb @@ -3,6 +3,6 @@ class DropIndexForBuildsProjectStatus < ActiveRecord::Migration DOWNTIME = false def change - remove_index(:ci_commits, [:gl_project_id, :status]) + remove_index(:ci_commits, column: [:gl_project_id, :status]) end end diff --git a/db/migrate/20170305203726_add_owner_id_foreign_key.rb b/db/migrate/20170305203726_add_owner_id_foreign_key.rb index 3eece0e2eb5..5fbdc45f1a7 100644 --- a/db/migrate/20170305203726_add_owner_id_foreign_key.rb +++ b/db/migrate/20170305203726_add_owner_id_foreign_key.rb @@ -5,7 +5,11 @@ class AddOwnerIdForeignKey < ActiveRecord::Migration disable_ddl_transaction! - def change + def up add_concurrent_foreign_key :ci_triggers, :users, column: :owner_id, on_delete: :cascade end + + def down + remove_foreign_key :ci_triggers, column: :owner_id + end end -- cgit v1.2.3 From 203bb0bc546cfa99272a858426904030d9292615 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 15 Mar 2017 11:50:20 -0700 Subject: Revert "Merge branch 'option-to-be-notified-of-own-activity' into 'master' This reverts commit 5e9666880376b3f53edb95cba77b5642d3cc1810, reversing changes made to b35378a938e22f745b6c6ea32b53cb50f9b6c627. --- ...20170123061730_add_notified_of_own_activity_to_users.rb | 14 -------------- db/schema.rb | 1 - 2 files changed, 15 deletions(-) delete mode 100644 db/migrate/20170123061730_add_notified_of_own_activity_to_users.rb (limited to 'db') diff --git a/db/migrate/20170123061730_add_notified_of_own_activity_to_users.rb b/db/migrate/20170123061730_add_notified_of_own_activity_to_users.rb deleted file mode 100644 index f90637e1e35..00000000000 --- a/db/migrate/20170123061730_add_notified_of_own_activity_to_users.rb +++ /dev/null @@ -1,14 +0,0 @@ -class AddNotifiedOfOwnActivityToUsers < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - disable_ddl_transaction! - - DOWNTIME = false - - def up - add_column_with_default :users, :notified_of_own_activity, :boolean, default: false - end - - def down - remove_column :users, :notified_of_own_activity - end -end diff --git a/db/schema.rb b/db/schema.rb index ca88198079f..612a86c2612 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1318,7 +1318,6 @@ ActiveRecord::Schema.define(version: 20170313133418) do t.string "incoming_email_token" t.string "organization" t.boolean "authorized_projects_populated" - t.boolean "notified_of_own_activity", default: false, null: false t.boolean "ghost" end -- cgit v1.2.3 From 6ba69483bde804f9760d5b9519fd3c37820ef857 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 15 Mar 2017 13:58:08 -0400 Subject: Revert the AddNotifiedOfOwnActivityToUsers migration --- ...revert_add_notified_of_own_activity_to_users.rb | 24 ++++++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb (limited to 'db') diff --git a/db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb b/db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb new file mode 100644 index 00000000000..b39c0a3be0f --- /dev/null +++ b/db/migrate/20170315174634_revert_add_notified_of_own_activity_to_users.rb @@ -0,0 +1,24 @@ +class RevertAddNotifiedOfOwnActivityToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = false + + def up + if our_column_exists? + remove_column :users, :notified_of_own_activity + end + end + + def down + unless our_column_exists? + add_column_with_default :users, :notified_of_own_activity, :boolean, default: false + end + end + + private + + def our_column_exists? + column_exists?(:users, :notified_of_own_activity) + end +end diff --git a/db/schema.rb b/db/schema.rb index 612a86c2612..3bef910c1d6 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: 20170313133418) do +ActiveRecord::Schema.define(version: 20170315174634) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 0e9a5e73ca40a32507c8771dc8e650a0fb853c4b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 16 Mar 2017 09:57:53 +0100 Subject: Fix statements timeout in manual actions migration --- db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'db') diff --git a/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb b/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb index 9020e0d054c..ec6e8cdfc45 100644 --- a/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb +++ b/db/post_migrate/20170306170512_migrate_legacy_manual_actions.rb @@ -4,6 +4,8 @@ class MigrateLegacyManualActions < ActiveRecord::Migration DOWNTIME = false def up + disable_statement_timeout + execute <<-EOS UPDATE ci_builds SET status = 'manual', allow_failure = true WHERE ci_builds.when = 'manual' AND ci_builds.status = 'skipped'; @@ -11,6 +13,8 @@ class MigrateLegacyManualActions < ActiveRecord::Migration end def down + disable_statement_timeout + execute <<-EOS UPDATE ci_builds SET status = 'skipped', allow_failure = false WHERE ci_builds.when = 'manual' AND ci_builds.status = 'manual'; -- cgit v1.2.3 From 68e3fa0e58938152357c6fb5997f1229666b1d5c Mon Sep 17 00:00:00 2001 From: Alex Sanford Date: Fri, 17 Mar 2017 12:35:39 +0000 Subject: Add ability to disable Merge Request URL on push --- ...d_printing_merge_request_link_enabled_to_project.rb | 18 ++++++++++++++++++ db/schema.rb | 1 + 2 files changed, 19 insertions(+) create mode 100644 db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb (limited to 'db') diff --git a/db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb b/db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb new file mode 100644 index 00000000000..f54608ecceb --- /dev/null +++ b/db/migrate/20170301125302_add_printing_merge_request_link_enabled_to_project.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddPrintingMergeRequestLinkEnabledToProject < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + add_column_with_default(:projects, :printing_merge_request_link_enabled, :boolean, default: true) + end + + def down + remove_column(:projects, :printing_merge_request_link_enabled) + end +end diff --git a/db/schema.rb b/db/schema.rb index 3bef910c1d6..6eb3c95de93 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1003,6 +1003,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do t.boolean "lfs_enabled" t.text "description_html" t.boolean "only_allow_merge_if_all_discussions_are_resolved" + t.boolean "printing_merge_request_link_enabled", default: true, null: false end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree -- cgit v1.2.3 From 94c19fbfe87ed1e262bc7a88ca65719d7271ad7b Mon Sep 17 00:00:00 2001 From: Felipe Artur Date: Wed, 15 Mar 2017 17:58:09 -0300 Subject: Add closed_at field to issues --- db/migrate/20170315194013_add_closed_at_to_issues.rb | 7 +++++++ db/schema.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170315194013_add_closed_at_to_issues.rb (limited to 'db') diff --git a/db/migrate/20170315194013_add_closed_at_to_issues.rb b/db/migrate/20170315194013_add_closed_at_to_issues.rb new file mode 100644 index 00000000000..1326118cc8d --- /dev/null +++ b/db/migrate/20170315194013_add_closed_at_to_issues.rb @@ -0,0 +1,7 @@ +class AddClosedAtToIssues < ActiveRecord::Migration + DOWNTIME = false + + def change + add_column :issues, :closed_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 6eb3c95de93..e228b0a3568 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: 20170315174634) do +ActiveRecord::Schema.define(version: 20170315194013) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -531,6 +531,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do t.text "description_html" t.integer "time_estimate" t.integer "relative_position" + t.datetime "closed_at" end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree -- cgit v1.2.3 From 12dd5ac22110bc3327297232d96f2afebaefc5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Fri, 17 Mar 2017 23:06:11 +0000 Subject: All CI offline migrations --- ...621_add_index_for_latest_successful_pipeline.rb | 2 +- db/migrate/20170222143317_drop_ci_projects.rb | 34 ++++++ ...20170222143500_remove_old_project_id_columns.rb | 28 +++++ ...222143603_rename_gl_project_id_to_project_id.rb | 14 +++ ...0301195939_rename_ci_commits_to_ci_pipelines.rb | 10 ++ ...01205639_remove_unused_ci_tables_and_columns.rb | 83 +++++++++++++++ ...5640_migrate_build_events_to_pipeline_events.rb | 87 ++++++++++++++++ db/schema.rb | 116 +++------------------ 8 files changed, 272 insertions(+), 102 deletions(-) create mode 100644 db/migrate/20170222143317_drop_ci_projects.rb create mode 100644 db/migrate/20170222143500_remove_old_project_id_columns.rb create mode 100644 db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb create mode 100644 db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb create mode 100644 db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb create mode 100644 db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb (limited to 'db') diff --git a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb index 65adc90c2c1..8a96a784c97 100644 --- a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb +++ b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb @@ -5,7 +5,7 @@ class AddIndexForLatestSuccessfulPipeline < ActiveRecord::Migration disable_ddl_transaction! def up - add_concurrent_index :ci_commits, [:gl_project_id, :ref, :status] + add_concurrent_index(:ci_commits, [:gl_project_id, :ref, :status]) end def down diff --git a/db/migrate/20170222143317_drop_ci_projects.rb b/db/migrate/20170222143317_drop_ci_projects.rb new file mode 100644 index 00000000000..4db8658f36f --- /dev/null +++ b/db/migrate/20170222143317_drop_ci_projects.rb @@ -0,0 +1,34 @@ +class DropCiProjects < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + drop_table :ci_projects + end + + def down + create_table "ci_projects", force: :cascade do |t| + t.string "name" + t.integer "timeout", default: 3600, null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "token" + t.string "default_ref" + t.string "path" + t.boolean "always_build", default: false, null: false + t.integer "polling_interval" + t.boolean "public", default: false, null: false + t.string "ssh_url_to_repo" + t.integer "gitlab_id" + t.boolean "allow_git_fetch", default: true, null: false + t.string "email_recipients", default: "", null: false + t.boolean "email_add_pusher", default: true, null: false + t.boolean "email_only_broken_builds", default: true, null: false + t.string "skip_refs" + t.string "coverage_regex" + t.boolean "shared_runners_enabled", default: false + t.text "generated_yaml_config" + end + end +end diff --git a/db/migrate/20170222143500_remove_old_project_id_columns.rb b/db/migrate/20170222143500_remove_old_project_id_columns.rb new file mode 100644 index 00000000000..eac93e8e407 --- /dev/null +++ b/db/migrate/20170222143500_remove_old_project_id_columns.rb @@ -0,0 +1,28 @@ +class RemoveOldProjectIdColumns < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = true + DOWNTIME_REASON = 'Unused columns are being removed.' + + def up + remove_index :ci_builds, :project_id if + index_exists?(:ci_builds, :project_id) + + remove_column :ci_builds, :project_id + remove_column :ci_commits, :project_id + remove_column :ci_runner_projects, :project_id + remove_column :ci_triggers, :project_id + remove_column :ci_variables, :project_id + end + + def down + add_column :ci_builds, :project_id, :integer + add_column :ci_commits, :project_id, :integer + add_column :ci_runner_projects, :project_id, :integer + add_column :ci_triggers, :project_id, :integer + add_column :ci_variables, :project_id, :integer + + add_concurrent_index :ci_builds, :project_id + end +end diff --git a/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb new file mode 100644 index 00000000000..7c19d471557 --- /dev/null +++ b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb @@ -0,0 +1,14 @@ +class RenameGlProjectIdToProjectId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = true + DOWNTIME_REASON = 'Renaming an actively used column.' + + def change + rename_column :ci_builds, :gl_project_id, :project_id + rename_column :ci_commits, :gl_project_id, :project_id + rename_column :ci_runner_projects, :gl_project_id, :project_id + rename_column :ci_triggers, :gl_project_id, :project_id + rename_column :ci_variables, :gl_project_id, :project_id + end +end diff --git a/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb new file mode 100644 index 00000000000..4f061d96392 --- /dev/null +++ b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb @@ -0,0 +1,10 @@ +class RenameCiCommitsToCiPipelines < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = true + DOWNTIME_REASON = 'Rename table ci_commits to ci_pipelines' + + def change + rename_table 'ci_commits', 'ci_pipelines' + end +end diff --git a/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb new file mode 100644 index 00000000000..1e2abea5254 --- /dev/null +++ b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb @@ -0,0 +1,83 @@ +class RemoveUnusedCiTablesAndColumns < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = true + DOWNTIME_REASON = + 'Remove unused columns in used tables.' \ + ' Downtime required in case Rails caches them' + + def up + %w[ci_application_settings + ci_events + ci_jobs + ci_sessions + ci_taggings + ci_tags].each do |table| + drop_table(table) + end + + remove_column :ci_pipelines, :push_data, :text + remove_column :ci_builds, :job_id, :integer + remove_column :ci_builds, :deploy, :boolean + end + + def down + add_column :ci_builds, :deploy, :boolean + add_column :ci_builds, :job_id, :integer + add_column :ci_pipelines, :push_data, :text + + create_table "ci_tags", force: :cascade do |t| + t.string "name" + t.integer "taggings_count", default: 0 + end + + create_table "ci_taggings", force: :cascade do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", limit: 128 + t.datetime "created_at" + end + + add_index "ci_taggings", %w[taggable_id taggable_type context] + + create_table "ci_sessions", force: :cascade do |t| + t.string "session_id", null: false + t.text "data" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "ci_jobs", force: :cascade do |t| + t.integer "project_id", null: false + t.text "commands" + t.boolean "active", default: true, null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "name" + t.boolean "build_branches", default: true, null: false + t.boolean "build_tags", default: false, null: false + t.string "job_type", default: "parallel" + t.string "refs" + t.datetime "deleted_at" + end + + create_table "ci_events", force: :cascade do |t| + t.integer "project_id" + t.integer "user_id" + t.integer "is_admin" + t.text "description" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "ci_application_settings", force: :cascade do |t| + t.boolean "all_broken_builds" + t.boolean "add_pusher" + t.datetime "created_at" + t.datetime "updated_at" + end + end +end diff --git a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb new file mode 100644 index 00000000000..2dd14ee5a78 --- /dev/null +++ b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb @@ -0,0 +1,87 @@ +class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + include Gitlab::Database + + DOWNTIME = false + + def up + Gitlab::Database.with_connection_pool(2) do |pool| + threads = [] + + threads << Thread.new do + pool.with_connection do |connection| + Thread.current[:foreign_key_connection] = connection + + execute(<<-SQL.strip_heredoc) + UPDATE services + SET properties = replace(properties, + 'notify_only_broken_builds', + 'notify_only_broken_pipelines') + , pipeline_events = #{true_value} + , build_events = #{false_value} + WHERE type IN + ('SlackService', 'MattermostService', 'HipchatService') + AND build_events = #{true_value}; + SQL + end + end + + threads << Thread.new do + pool.with_connection do |connection| + Thread.current[:foreign_key_connection] = connection + + execute(update_pipeline_services_sql) + end + end + + threads.each(&:join) + end + end + + def down + # Don't bother to migrate the data back + end + + def connection + # Rails memoizes connection objects, but this causes them to be shared + # amongst threads; we don't want that. + Thread.current[:foreign_key_connection] || ActiveRecord::Base.connection + end + + private + + def update_pipeline_services_sql + if Gitlab::Database.postgresql? + <<-SQL + UPDATE services + SET type = 'PipelinesEmailService' + , properties = replace(properties, + 'notify_only_broken_builds', + 'notify_only_broken_pipelines') + , pipeline_events = #{true_value} + , build_events = #{false_value} + WHERE type = 'BuildsEmailService' + AND + (SELECT 1 FROM services pipeline_services + WHERE pipeline_services.project_id = services.project_id + AND pipeline_services.type = 'PipelinesEmailService' LIMIT 1) + IS NULL; + SQL + else + <<-SQL + UPDATE services build_services + LEFT OUTER JOIN services pipeline_services + ON build_services.project_id = pipeline_services.project_id + AND pipeline_services.type = 'PipelinesEmailService' + SET build_services.type = 'PipelinesEmailService' + , build_services.properties = replace(build_services.properties, + 'notify_only_broken_builds', + 'notify_only_broken_pipelines') + , build_services.pipeline_events = #{true_value} + , build_services.build_events = #{false_value} + WHERE build_services.type = 'BuildsEmailService' + AND pipeline_services.id IS NULL; + SQL + end.strip_heredoc + end +end diff --git a/db/schema.rb b/db/schema.rb index 6eb3c95de93..634d02bb5bc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -185,15 +185,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do add_index "chat_teams", ["namespace_id"], name: "index_chat_teams_on_namespace_id", unique: true, using: :btree - create_table "ci_application_settings", force: :cascade do |t| - t.boolean "all_broken_builds" - t.boolean "add_pusher" - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "ci_builds", force: :cascade do |t| - t.integer "project_id" t.string "status" t.datetime "finished_at" t.text "trace" @@ -204,9 +196,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do t.float "coverage" t.integer "commit_id" t.text "commands" - t.integer "job_id" t.string "name" - t.boolean "deploy", default: false t.text "options" t.boolean "allow_failure", default: false, null: false t.string "stage" @@ -219,7 +209,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do t.string "target_url" t.string "description" t.text "artifacts_file" - t.integer "gl_project_id" + t.integer "project_id" t.text "artifacts_metadata" t.integer "erased_by_id" t.datetime "erased_at" @@ -238,25 +228,22 @@ ActiveRecord::Schema.define(version: 20170315174634) do add_index "ci_builds", ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type", using: :btree add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree - add_index "ci_builds", ["gl_project_id"], name: "index_ci_builds_on_gl_project_id", using: :btree add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree add_index "ci_builds", ["status", "type", "runner_id"], name: "index_ci_builds_on_status_and_type_and_runner_id", using: :btree add_index "ci_builds", ["status"], name: "index_ci_builds_on_status", using: :btree add_index "ci_builds", ["token"], name: "index_ci_builds_on_token", unique: true, using: :btree - create_table "ci_commits", force: :cascade do |t| - t.integer "project_id" + create_table "ci_pipelines", force: :cascade do |t| t.string "ref" t.string "sha" t.string "before_sha" - t.text "push_data" t.datetime "created_at" t.datetime "updated_at" t.boolean "tag", default: false t.text "yaml_errors" t.datetime "committed_at" - t.integer "gl_project_id" + t.integer "project_id" t.string "status" t.datetime "started_at" t.datetime "finished_at" @@ -265,67 +252,20 @@ ActiveRecord::Schema.define(version: 20170315174634) do t.integer "lock_version" end - add_index "ci_commits", ["gl_project_id", "ref", "status"], name: "index_ci_commits_on_gl_project_id_and_ref_and_status", using: :btree - add_index "ci_commits", ["gl_project_id", "sha"], name: "index_ci_commits_on_gl_project_id_and_sha", using: :btree - add_index "ci_commits", ["gl_project_id"], name: "index_ci_commits_on_gl_project_id", using: :btree - add_index "ci_commits", ["status"], name: "index_ci_commits_on_status", using: :btree - add_index "ci_commits", ["user_id"], name: "index_ci_commits_on_user_id", using: :btree - - create_table "ci_events", force: :cascade do |t| - t.integer "project_id" - t.integer "user_id" - t.integer "is_admin" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "ci_jobs", force: :cascade do |t| - t.integer "project_id", null: false - t.text "commands" - t.boolean "active", default: true, null: false - t.datetime "created_at" - t.datetime "updated_at" - t.string "name" - t.boolean "build_branches", default: true, null: false - t.boolean "build_tags", default: false, null: false - t.string "job_type", default: "parallel" - t.string "refs" - t.datetime "deleted_at" - end - - create_table "ci_projects", force: :cascade do |t| - t.string "name" - t.integer "timeout", default: 3600, null: false - t.datetime "created_at" - t.datetime "updated_at" - t.string "token" - t.string "default_ref" - t.string "path" - t.boolean "always_build", default: false, null: false - t.integer "polling_interval" - t.boolean "public", default: false, null: false - t.string "ssh_url_to_repo" - t.integer "gitlab_id" - t.boolean "allow_git_fetch", default: true, null: false - t.string "email_recipients", default: "", null: false - t.boolean "email_add_pusher", default: true, null: false - t.boolean "email_only_broken_builds", default: true, null: false - t.string "skip_refs" - t.string "coverage_regex" - t.boolean "shared_runners_enabled", default: false - t.text "generated_yaml_config" - end + add_index "ci_pipelines", ["project_id", "ref", "status"], name: "index_ci_pipelines_on_project_id_and_ref_and_status", using: :btree + add_index "ci_pipelines", ["project_id", "sha"], name: "index_ci_pipelines_on_project_id_and_sha", using: :btree + add_index "ci_pipelines", ["project_id"], name: "index_ci_pipelines_on_project_id", using: :btree + add_index "ci_pipelines", ["status"], name: "index_ci_pipelines_on_status", using: :btree + add_index "ci_pipelines", ["user_id"], name: "index_ci_pipelines_on_user_id", using: :btree create_table "ci_runner_projects", force: :cascade do |t| t.integer "runner_id", null: false - t.integer "project_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "gl_project_id" + t.integer "project_id" end - add_index "ci_runner_projects", ["gl_project_id"], name: "index_ci_runner_projects_on_gl_project_id", using: :btree + add_index "ci_runner_projects", ["project_id"], name: "index_ci_runner_projects_on_project_id", using: :btree add_index "ci_runner_projects", ["runner_id"], name: "index_ci_runner_projects_on_runner_id", using: :btree create_table "ci_runners", force: :cascade do |t| @@ -349,30 +289,6 @@ ActiveRecord::Schema.define(version: 20170315174634) do 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 - create_table "ci_sessions", force: :cascade do |t| - t.string "session_id", null: false - t.text "data" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "ci_taggings", force: :cascade do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", limit: 128 - t.datetime "created_at" - end - - add_index "ci_taggings", ["taggable_id", "taggable_type", "context"], name: "index_ci_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - - create_table "ci_tags", force: :cascade do |t| - t.string "name" - t.integer "taggings_count", default: 0 - end - create_table "ci_trigger_requests", force: :cascade do |t| t.integer "trigger_id", null: false t.text "variables" @@ -385,28 +301,26 @@ ActiveRecord::Schema.define(version: 20170315174634) do create_table "ci_triggers", force: :cascade do |t| t.string "token" - t.integer "project_id" t.datetime "deleted_at" t.datetime "created_at" t.datetime "updated_at" - t.integer "gl_project_id" + t.integer "project_id" t.integer "owner_id" t.string "description" end - add_index "ci_triggers", ["gl_project_id"], name: "index_ci_triggers_on_gl_project_id", using: :btree + add_index "ci_triggers", ["project_id"], name: "index_ci_triggers_on_project_id", using: :btree create_table "ci_variables", force: :cascade do |t| - t.integer "project_id" t.string "key" t.text "value" t.text "encrypted_value" t.string "encrypted_value_salt" t.string "encrypted_value_iv" - t.integer "gl_project_id" + t.integer "project_id" end - add_index "ci_variables", ["gl_project_id"], name: "index_ci_variables_on_gl_project_id", using: :btree + add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree create_table "deploy_keys_projects", force: :cascade do |t| t.integer "deploy_key_id", null: false @@ -1378,7 +1292,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do add_foreign_key "labels", "namespaces", column: "group_id", on_delete: :cascade add_foreign_key "lists", "boards" add_foreign_key "lists", "labels" - add_foreign_key "merge_request_metrics", "ci_commits", column: "pipeline_id", on_delete: :cascade + add_foreign_key "merge_request_metrics", "ci_pipelines", column: "pipeline_id", on_delete: :cascade add_foreign_key "merge_request_metrics", "merge_requests", on_delete: :cascade add_foreign_key "merge_requests_closing_issues", "issues", on_delete: :cascade add_foreign_key "merge_requests_closing_issues", "merge_requests", on_delete: :cascade -- cgit v1.2.3 From 04f62ac235f9b5e8b33ff2429cec3376a7608738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 20 Mar 2017 14:47:50 +0100 Subject: Remove useless options from db/fixtures/development/17_cycle_analytics.rb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- 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 aea0a72b633..4bc735916c1 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -155,7 +155,7 @@ class Gitlab::Seeder::CycleAnalytics issue.project.repository.add_branch(@user, branch_name, 'master') - commit_sha = issue.project.repository.create_file(@user, filename, "content", options, message: "Commit for ##{issue.iid}", branch_name: branch_name) + commit_sha = issue.project.repository.create_file(@user, filename, "content", message: "Commit for ##{issue.iid}", branch_name: branch_name) issue.project.repository.commit(commit_sha) GitPushService.new(issue.project, -- cgit v1.2.3 From ca0d84384dd3ea6d9d3b9a365ab84e5f25276524 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 16 Mar 2017 16:44:13 +0200 Subject: Improve rename projects migration Signed-off-by: Dmitriy Zaporozhets --- ...313133418_rename_more_reserved_project_names.rb | 31 +--------------------- 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'db') diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb index 9dfe77bedb7..44c688fa134 100644 --- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb +++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb @@ -6,41 +6,12 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration DOWNTIME = false - THREAD_COUNT = 8 - KNOWN_PATHS = %w(artifacts graphs refs badges).freeze def up - queues = Array.new(THREAD_COUNT) { Queue.new } - start = false - - threads = Array.new(THREAD_COUNT) do |index| - Thread.new do - queue = queues[index] - - # Wait until we have input to process. - until start; end - - rename_projects(queue.pop) until queue.empty? - end - end - - enum = queues.each - reserved_projects.each_slice(100) do |slice| - begin - queue = enum.next - rescue StopIteration - enum.rewind - retry - end - - queue << slice + rename_projects(slice) end - - start = true - - threads.each(&:join) end def down -- cgit v1.2.3 From 2de768e23a40fa62235f95426c0204a8651f545d Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Mon, 13 Mar 2017 14:46:15 -0700 Subject: add an index to the ghost column --- .../20170313213916_add_index_to_user_ghost.rb | 24 ++++++++++++++++++++++ db/schema.rb | 7 ++++--- 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20170313213916_add_index_to_user_ghost.rb (limited to 'db') diff --git a/db/migrate/20170313213916_add_index_to_user_ghost.rb b/db/migrate/20170313213916_add_index_to_user_ghost.rb new file mode 100644 index 00000000000..c429039c275 --- /dev/null +++ b/db/migrate/20170313213916_add_index_to_user_ghost.rb @@ -0,0 +1,24 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexToUserGhost < 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 = '' + + disable_ddl_transaction! + + def up + add_concurrent_index :users, :ghost + end + + def down + remove_index :users, :ghost + end +end diff --git a/db/schema.rb b/db/schema.rb index ee5000ea64c..f96a7d21890 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,7 +61,6 @@ ActiveRecord::Schema.define(version: 20170315194013) 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,6 +110,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do t.string "plantuml_url" t.boolean "plantuml_enabled" t.integer "terminal_max_session_time", default: 0, null: false + t.integer "max_pages_size", default: 100, 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" @@ -688,8 +688,8 @@ ActiveRecord::Schema.define(version: 20170315194013) 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" end @@ -1231,8 +1231,8 @@ ActiveRecord::Schema.define(version: 20170315194013) do t.datetime "otp_grace_period_started_at" t.boolean "ldap_email", default: false, null: false t.boolean "external", default: false - t.string "incoming_email_token" t.string "organization" + t.string "incoming_email_token" t.boolean "authorized_projects_populated" t.boolean "ghost" end @@ -1244,6 +1244,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do add_index "users", ["current_sign_in_at"], name: "index_users_on_current_sign_in_at", using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email_trigram", using: :gin, opclasses: {"email"=>"gin_trgm_ops"} + add_index "users", ["ghost"], name: "index_users_on_ghost", using: :btree add_index "users", ["incoming_email_token"], name: "index_users_on_incoming_email_token", using: :btree add_index "users", ["name"], name: "index_users_on_name", using: :btree add_index "users", ["name"], name: "index_users_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} -- cgit v1.2.3