From dcd4beb8eb7bb7d0c2f720ef85c3da9f97a3dfe6 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Wed, 2 Nov 2016 00:33:35 -0200 Subject: Multi-level container image names backend implementation - Adds Registry events API endpoint - Adds container_images_repository and container_images models - Changes JWT authentication to allow multi-level scopes - Adds services for container image maintenance --- ...029153736_create_container_images_repository.rb | 31 +++++++++++++++++++++ .../20161031013926_create_container_image.rb | 32 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 db/migrate/20161029153736_create_container_images_repository.rb create mode 100644 db/migrate/20161031013926_create_container_image.rb (limited to 'db') diff --git a/db/migrate/20161029153736_create_container_images_repository.rb b/db/migrate/20161029153736_create_container_images_repository.rb new file mode 100644 index 00000000000..d93180b1674 --- /dev/null +++ b/db/migrate/20161029153736_create_container_images_repository.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 CreateContainerImagesRepository < 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 + create_table :container_images_repositories do |t| + t.integer :project_id, null: false + end + end +end diff --git a/db/migrate/20161031013926_create_container_image.rb b/db/migrate/20161031013926_create_container_image.rb new file mode 100644 index 00000000000..94feae280a6 --- /dev/null +++ b/db/migrate/20161031013926_create_container_image.rb @@ -0,0 +1,32 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateContainerImage < 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 + create_table :container_images do |t| + t.integer :container_images_repository_id + t.string :name + end + end +end -- cgit v1.2.3 From eed0b85ad084ad4d13cc26907102063d9372fe75 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Wed, 23 Nov 2016 14:50:30 -0200 Subject: First iteration of container_image view - Fixes project, container_image and tag deletion - Removed container_images_repository [ci skip] --- ...029153736_create_container_images_repository.rb | 31 ---------------------- .../20161031013926_create_container_image.rb | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 db/migrate/20161029153736_create_container_images_repository.rb (limited to 'db') diff --git a/db/migrate/20161029153736_create_container_images_repository.rb b/db/migrate/20161029153736_create_container_images_repository.rb deleted file mode 100644 index d93180b1674..00000000000 --- a/db/migrate/20161029153736_create_container_images_repository.rb +++ /dev/null @@ -1,31 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CreateContainerImagesRepository < 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 - create_table :container_images_repositories do |t| - t.integer :project_id, null: false - end - end -end diff --git a/db/migrate/20161031013926_create_container_image.rb b/db/migrate/20161031013926_create_container_image.rb index 94feae280a6..85c0913b8f3 100644 --- a/db/migrate/20161031013926_create_container_image.rb +++ b/db/migrate/20161031013926_create_container_image.rb @@ -25,7 +25,7 @@ class CreateContainerImage < ActiveRecord::Migration def change create_table :container_images do |t| - t.integer :container_images_repository_id + t.integer :project_id t.string :name end end -- cgit v1.2.3 From 246df2bd1151d39a04ef553064144eb75ee3e980 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Tue, 13 Dec 2016 23:42:43 -0200 Subject: Adding registry endpoint authorization --- ...egistry_access_token_to_application_settings.rb | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb b/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb new file mode 100644 index 00000000000..f89f9b00a5f --- /dev/null +++ b/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.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 AddContainerRegistryAccessTokenToApplicationSettings < 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 :application_settings, :container_registry_access_token, :string + end +end -- cgit v1.2.3 From e4fa80f3b67f1ef30c262cd4df28516ccff6336a Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Fri, 16 Dec 2016 01:24:05 -0200 Subject: Fixes broken and missing tests --- db/schema.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 88aaa6c3c55..36df20fc8f2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -109,6 +109,7 @@ ActiveRecord::Schema.define(version: 20170215200045) do t.boolean "html_emails_enabled", default: true t.string "plantuml_url" t.boolean "plantuml_enabled" + t.string "container_registry_access_token" t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false end @@ -392,6 +393,11 @@ ActiveRecord::Schema.define(version: 20170215200045) do add_index "ci_variables", ["gl_project_id"], name: "index_ci_variables_on_gl_project_id", using: :btree + create_table "container_images", force: :cascade do |t| + t.integer "project_id" + t.string "name" + end + create_table "deploy_keys_projects", force: :cascade do |t| t.integer "deploy_key_id", null: false t.integer "project_id", null: false -- cgit v1.2.3 From db5b4b8b1a9b8aa07c8310dde53b7c3ed391bafd Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Wed, 22 Feb 2017 11:19:23 -0300 Subject: Creates specs for destroy service and improves namespace container image query performance --- db/migrate/20161031013926_create_container_image.rb | 16 ---------------- ...iner_registry_access_token_to_application_settings.rb | 16 ---------------- db/schema.rb | 10 +++++----- 3 files changed, 5 insertions(+), 37 deletions(-) (limited to 'db') diff --git a/db/migrate/20161031013926_create_container_image.rb b/db/migrate/20161031013926_create_container_image.rb index 85c0913b8f3..884c78880eb 100644 --- a/db/migrate/20161031013926_create_container_image.rb +++ b/db/migrate/20161031013926_create_container_image.rb @@ -7,22 +7,6 @@ class CreateContainerImage < ActiveRecord::Migration # 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 create_table :container_images do |t| t.integer :project_id diff --git a/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb b/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb index f89f9b00a5f..23d87cc6d0a 100644 --- a/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb +++ b/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb @@ -7,22 +7,6 @@ class AddContainerRegistryAccessTokenToApplicationSettings < ActiveRecord::Migra # 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 :application_settings, :container_registry_access_token, :string end diff --git a/db/schema.rb b/db/schema.rb index 36df20fc8f2..08d11546800 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 @@ -107,10 +108,9 @@ ActiveRecord::Schema.define(version: 20170215200045) do t.string "sidekiq_throttling_queues" t.decimal "sidekiq_throttling_factor" t.boolean "html_emails_enabled", default: true + t.string "container_registry_access_token" t.string "plantuml_url" t.boolean "plantuml_enabled" - t.string "container_registry_access_token" - t.integer "max_pages_size", default: 100, null: false t.integer "terminal_max_session_time", default: 0, null: false end @@ -586,9 +586,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 @@ -761,8 +761,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 @@ -1283,8 +1283,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 c64d36306cafac463f20d49e750f397a9b32960b Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Tue, 21 Mar 2017 10:35:02 -0300 Subject: Makes ContainerImages Routable Conflicts: db/schema.rb --- db/migrate/20161031013926_create_container_image.rb | 1 + db/schema.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20161031013926_create_container_image.rb b/db/migrate/20161031013926_create_container_image.rb index 884c78880eb..06c409857da 100644 --- a/db/migrate/20161031013926_create_container_image.rb +++ b/db/migrate/20161031013926_create_container_image.rb @@ -11,6 +11,7 @@ class CreateContainerImage < ActiveRecord::Migration create_table :container_images do |t| t.integer :project_id t.string :name + t.string :path end end end diff --git a/db/schema.rb b/db/schema.rb index db57fb0a548..a1fc5dc1f58 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -108,7 +108,6 @@ ActiveRecord::Schema.define(version: 20170315194013) do t.string "sidekiq_throttling_queues" t.decimal "sidekiq_throttling_factor" t.boolean "html_emails_enabled", default: true - t.string "container_registry_access_token" t.string "plantuml_url" t.boolean "plantuml_enabled" t.integer "terminal_max_session_time", default: 0, null: false @@ -117,6 +116,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false + t.string "container_registry_access_token" end create_table "audit_events", force: :cascade do |t| @@ -327,6 +327,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do create_table "container_images", force: :cascade do |t| t.integer "project_id" t.string "name" + t.string "path" end create_table "deploy_keys_projects", force: :cascade do |t| -- cgit v1.2.3 From 68a2fa54dedcdbe893ec811413d1703e5f6ac2dc Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 22 Mar 2017 11:08:23 +0100 Subject: Remove out-of-scope changes for multi-level images --- ...ntainer_registry_access_token_to_application_settings.rb | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb b/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb deleted file mode 100644 index 23d87cc6d0a..00000000000 --- a/db/migrate/20161213212947_add_container_registry_access_token_to_application_settings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddContainerRegistryAccessTokenToApplicationSettings < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - add_column :application_settings, :container_registry_access_token, :string - end -end -- cgit v1.2.3 From 29c34267556198ee3dbbe2f13bc81708f5e60f10 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 22 Mar 2017 11:41:05 +0100 Subject: Move container images migration to the present time --- db/migrate/20161031013926_create_container_image.rb | 17 ----------------- db/migrate/20170322013926_create_container_image.rb | 13 +++++++++++++ 2 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 db/migrate/20161031013926_create_container_image.rb create mode 100644 db/migrate/20170322013926_create_container_image.rb (limited to 'db') diff --git a/db/migrate/20161031013926_create_container_image.rb b/db/migrate/20161031013926_create_container_image.rb deleted file mode 100644 index 06c409857da..00000000000 --- a/db/migrate/20161031013926_create_container_image.rb +++ /dev/null @@ -1,17 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CreateContainerImage < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - # Set this constant to true if this migration requires downtime. - DOWNTIME = false - - def change - create_table :container_images do |t| - t.integer :project_id - t.string :name - t.string :path - end - end -end diff --git a/db/migrate/20170322013926_create_container_image.rb b/db/migrate/20170322013926_create_container_image.rb new file mode 100644 index 00000000000..c494f2a56c7 --- /dev/null +++ b/db/migrate/20170322013926_create_container_image.rb @@ -0,0 +1,13 @@ +class CreateContainerImage < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :container_images do |t| + t.integer :project_id + t.string :name + t.string :path + end + end +end -- cgit v1.2.3 From bd8c8df6ed8dd7321608ce652e23d86ef3bd6899 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 23 Mar 2017 12:01:12 +0100 Subject: Fix database schema --- db/schema.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index a1fc5dc1f58..b5bd6fc3121 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: 20170315194013) do +ActiveRecord::Schema.define(version: 20170322013926) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -111,12 +111,10 @@ 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" t.boolean "unique_ips_limit_enabled", default: false, null: false - t.string "container_registry_access_token" end create_table "audit_events", force: :cascade do |t| @@ -993,6 +991,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do end add_index "routes", ["path"], name: "index_routes_on_path", unique: true, using: :btree + add_index "routes", ["path"], name: "index_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} add_index "routes", ["source_type", "source_id"], name: "index_routes_on_source_type_and_source_id", unique: true, using: :btree create_table "sent_notifications", force: :cascade do |t| -- cgit v1.2.3 From 01d159b409d8b24d36204979a73de249843d71bf Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 23 Mar 2017 14:00:41 +0100 Subject: Rename container image model to container repository --- db/migrate/20170322013926_create_container_image.rb | 13 ------------- db/migrate/20170322013926_create_container_repository.rb | 12 ++++++++++++ db/schema.rb | 10 ++++------ 3 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 db/migrate/20170322013926_create_container_image.rb create mode 100644 db/migrate/20170322013926_create_container_repository.rb (limited to 'db') diff --git a/db/migrate/20170322013926_create_container_image.rb b/db/migrate/20170322013926_create_container_image.rb deleted file mode 100644 index c494f2a56c7..00000000000 --- a/db/migrate/20170322013926_create_container_image.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateContainerImage < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - create_table :container_images do |t| - t.integer :project_id - t.string :name - t.string :path - end - end -end diff --git a/db/migrate/20170322013926_create_container_repository.rb b/db/migrate/20170322013926_create_container_repository.rb new file mode 100644 index 00000000000..0235fd7e096 --- /dev/null +++ b/db/migrate/20170322013926_create_container_repository.rb @@ -0,0 +1,12 @@ +class CreateContainerRepository < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :container_repositories do |t| + t.integer :project_id + t.string :path + end + end +end diff --git a/db/schema.rb b/db/schema.rb index b5bd6fc3121..be7604a14d5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,7 +61,6 @@ ActiveRecord::Schema.define(version: 20170322013926) 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: 20170322013926) 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" @@ -322,9 +322,8 @@ ActiveRecord::Schema.define(version: 20170322013926) do add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree - create_table "container_images", force: :cascade do |t| + create_table "container_repositories", force: :cascade do |t| t.integer "project_id" - t.string "name" t.string "path" end @@ -694,8 +693,8 @@ ActiveRecord::Schema.define(version: 20170322013926) 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 @@ -991,7 +990,6 @@ ActiveRecord::Schema.define(version: 20170322013926) do end add_index "routes", ["path"], name: "index_routes_on_path", unique: true, using: :btree - add_index "routes", ["path"], name: "index_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} add_index "routes", ["source_type", "source_id"], name: "index_routes_on_source_type_and_source_id", unique: true, using: :btree create_table "sent_notifications", force: :cascade do |t| @@ -1238,8 +1236,8 @@ ActiveRecord::Schema.define(version: 20170322013926) 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 -- cgit v1.2.3 From ea16ea5bfcb78f66c6bb37e470d387bf1ac26c9f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 23 Mar 2017 14:09:01 +0100 Subject: Identify container repository by a single name --- db/migrate/20170322013926_create_container_repository.rb | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170322013926_create_container_repository.rb b/db/migrate/20170322013926_create_container_repository.rb index 0235fd7e096..87a1523724c 100644 --- a/db/migrate/20170322013926_create_container_repository.rb +++ b/db/migrate/20170322013926_create_container_repository.rb @@ -6,7 +6,7 @@ class CreateContainerRepository < ActiveRecord::Migration def change create_table :container_repositories do |t| t.integer :project_id - t.string :path + t.string :name end end end diff --git a/db/schema.rb b/db/schema.rb index be7604a14d5..5d9b219ebea 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -324,7 +324,7 @@ ActiveRecord::Schema.define(version: 20170322013926) do create_table "container_repositories", force: :cascade do |t| t.integer "project_id" - t.string "path" + t.string "name" end create_table "deploy_keys_projects", force: :cascade do |t| -- cgit v1.2.3 From 1c3c7fb25d972fc19d5b4bb371cb21094d81e478 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Wed, 15 Mar 2017 14:18:44 +0100 Subject: Add system_note_metadata model --- .../20170314082049_create_system_note_metadata.rb | 19 +++++++++++++++++++ db/schema.rb | 9 +++++++++ 2 files changed, 28 insertions(+) create mode 100644 db/migrate/20170314082049_create_system_note_metadata.rb (limited to 'db') diff --git a/db/migrate/20170314082049_create_system_note_metadata.rb b/db/migrate/20170314082049_create_system_note_metadata.rb new file mode 100644 index 00000000000..c58da88631f --- /dev/null +++ b/db/migrate/20170314082049_create_system_note_metadata.rb @@ -0,0 +1,19 @@ +class CreateSystemNoteMetadata < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def change + create_table :system_note_metadata do |t| + t.references :note, null: false + t.integer :commit_count + t.string :icon + + t.timestamps null: false + end + + add_concurrent_foreign_key :system_note_metadata, :notes, column: :note_id, on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index f476637ceb2..456dbd41230 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1075,6 +1075,14 @@ ActiveRecord::Schema.define(version: 20170317203554) do add_index "subscriptions", ["subscribable_id", "subscribable_type", "user_id", "project_id"], name: "index_subscriptions_on_subscribable_and_user_id_and_project_id", unique: true, using: :btree + create_table "system_note_metadata", force: :cascade do |t| + t.integer "note_id", null: false + t.integer "commit_count" + t.string "icon" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "taggings", force: :cascade do |t| t.integer "tag_id" t.integer "taggable_id" @@ -1308,6 +1316,7 @@ ActiveRecord::Schema.define(version: 20170317203554) do add_foreign_key "protected_branch_merge_access_levels", "protected_branches" add_foreign_key "protected_branch_push_access_levels", "protected_branches" add_foreign_key "subscriptions", "projects", on_delete: :cascade + add_foreign_key "system_note_metadata", "notes", name: "fk_d83a918cb1", on_delete: :cascade add_foreign_key "timelogs", "issues", name: "fk_timelogs_issues_issue_id", on_delete: :cascade 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 -- cgit v1.2.3 From c729d9dae7ad8c32cbe93b590baa24c8133364e5 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Wed, 15 Mar 2017 14:19:45 +0100 Subject: Create metadata when creating system notes --- db/migrate/20170314082049_create_system_note_metadata.rb | 10 +++++++--- db/schema.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20170314082049_create_system_note_metadata.rb b/db/migrate/20170314082049_create_system_note_metadata.rb index c58da88631f..dd1e6cf8172 100644 --- a/db/migrate/20170314082049_create_system_note_metadata.rb +++ b/db/migrate/20170314082049_create_system_note_metadata.rb @@ -5,15 +5,19 @@ class CreateSystemNoteMetadata < ActiveRecord::Migration disable_ddl_transaction! - def change + def up create_table :system_note_metadata do |t| t.references :note, null: false t.integer :commit_count - t.string :icon + t.string :action t.timestamps null: false end - add_concurrent_foreign_key :system_note_metadata, :notes, column: :note_id, on_delete: :cascade + add_concurrent_foreign_key :system_note_metadata, :notes, column: :note_id + end + + def down + drop_table :system_note_metadata end end diff --git a/db/schema.rb b/db/schema.rb index 456dbd41230..dba242548c1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1078,7 +1078,7 @@ ActiveRecord::Schema.define(version: 20170317203554) do create_table "system_note_metadata", force: :cascade do |t| t.integer "note_id", null: false t.integer "commit_count" - t.string "icon" + t.string "action" t.datetime "created_at", null: false t.datetime "updated_at", null: false end -- cgit v1.2.3 From 53ef1de4fcdc7ea0f94ae8fe73f9a2b46e376223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 30 Mar 2017 10:41:45 +0200 Subject: Fix production admin fixture to use the new `Users::CreateService` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/fixtures/production/001_admin.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/fixtures/production/001_admin.rb b/db/fixtures/production/001_admin.rb index b37dc794015..1c7c89f7bbd 100644 --- a/db/fixtures/production/001_admin.rb +++ b/db/fixtures/production/001_admin.rb @@ -12,10 +12,12 @@ else user_args[:password] = ENV['GITLAB_ROOT_PASSWORD'] end -user = User.new(user_args) -user.skip_confirmation! +# Only admins can create other admin users in Users::CreateService so to solve +# the chicken-and-egg problem, we pass a non-persisted admin user to the service. +transient_admin = User.new(admin: true) +user = Users::CreateService.new(transient_admin, user_args.merge!(skip_confirmation: true)).execute -if user.save +if user.persisted? puts "Administrator account created:".color(:green) puts puts "login: root".color(:green) -- cgit v1.2.3 From 1a416a42f1c1b876ecd96687e41696bc915cc2c2 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Wed, 15 Mar 2017 22:26:48 +0000 Subject: Database migrations for protected tags Added schema.rb for protected tags --- db/migrate/20170309173138_create_protected_tags.rb | 39 ++++++++++++++++++++++ db/schema.rb | 30 ++++++++++++++++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170309173138_create_protected_tags.rb (limited to 'db') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb new file mode 100644 index 00000000000..c69ef970410 --- /dev/null +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -0,0 +1,39 @@ +class CreateProtectedTags < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + GitlabAccessMaster = 40 + + def change + create_table :protected_tags do |t| + t.integer :project_id, null: false + t.string :name, null: false + t.string :timestamps #TODO: `null: false`? Missing from protected_branches + end + + add_index :protected_tags, :project_id + + create_table :protected_tag_merge_access_levels do |t| + t.references :protected_tag, index: { name: "index_protected_tag_merge_access" }, foreign_key: true, null: false + + t.integer :access_level, default: GitlabAccessMaster, null: true #TODO: was false, check schema + t.integer :group_id #TODO: check why group/user id missing from CE + t.integer :user_id + t.timestamps null: false + end + + create_table :protected_tag_push_access_levels do |t| + t.references :protected_tag, index: { name: "index_protected_tag_push_access" }, foreign_key: true, null: false + t.integer :access_level, default: GitlabAccessMaster, null: true #TODO: was false, check schema + t.integer :group_id + t.integer :user_id + t.timestamps null: false + end + + #TODO: These had rubocop set to disable Migration/AddConcurrentForeignKey + # add_foreign_key :protected_tag_merge_access_levels, :namespaces, column: :group_id + # add_foreign_key :protected_tag_push_access_levels, :namespaces, column: :group_id + end +end diff --git a/db/schema.rb b/db/schema.rb index f96a7d21890..05b28b6a63b 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: 20170315194013) do +ActiveRecord::Schema.define(version: 20170317203554) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -963,6 +963,32 @@ ActiveRecord::Schema.define(version: 20170315194013) do add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree + create_table "protected_tag_merge_access_levels", force: :cascade do |t| + t.integer "protected_tag_id", null: false + t.integer "access_level", default: 40, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "protected_tag_merge_access_levels", ["protected_tag_id"], name: "index_protected_tag_merge_access", using: :btree + + create_table "protected_tag_push_access_levels", force: :cascade do |t| + t.integer "protected_tag_id", null: false + t.integer "access_level", default: 40, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "protected_tag_push_access_levels", ["protected_tag_id"], name: "index_protected_tag_push_access", using: :btree + + create_table "protected_tags", force: :cascade do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.string "timestamps" + end + + add_index "protected_tags", ["project_id"], name: "index_protected_tags_on_project_id", using: :btree + create_table "releases", force: :cascade do |t| t.string "tag" t.text "description" @@ -1305,6 +1331,8 @@ ActiveRecord::Schema.define(version: 20170315194013) do add_foreign_key "project_statistics", "projects", on_delete: :cascade add_foreign_key "protected_branch_merge_access_levels", "protected_branches" add_foreign_key "protected_branch_push_access_levels", "protected_branches" + add_foreign_key "protected_tag_merge_access_levels", "protected_tags" + add_foreign_key "protected_tag_push_access_levels", "protected_tags" add_foreign_key "subscriptions", "projects", on_delete: :cascade add_foreign_key "timelogs", "issues", name: "fk_timelogs_issues_issue_id", on_delete: :cascade add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade -- cgit v1.2.3 From b5fce1d5ac87546e8f31fb0ef6f6c4d514670198 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Fri, 31 Mar 2017 17:56:26 +0100 Subject: =?UTF-8?q?Removed=20unnecessary=20table=20=E2=80=98protected=5Fta?= =?UTF-8?q?g=5Fmerge=5Faccess=5Flevels=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed timestamps on protected_tags --- db/migrate/20170309173138_create_protected_tags.rb | 23 ++++++---------------- db/schema.rb | 22 +++++++++------------ 2 files changed, 15 insertions(+), 30 deletions(-) (limited to 'db') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb index c69ef970410..00794529143 100644 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -4,36 +4,25 @@ class CreateProtectedTags < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - GitlabAccessMaster = 40 + GITLAB_ACCESS_MASTER = 40 def change create_table :protected_tags do |t| t.integer :project_id, null: false t.string :name, null: false - t.string :timestamps #TODO: `null: false`? Missing from protected_branches + t.timestamps null: false end add_index :protected_tags, :project_id - create_table :protected_tag_merge_access_levels do |t| - t.references :protected_tag, index: { name: "index_protected_tag_merge_access" }, foreign_key: true, null: false - - t.integer :access_level, default: GitlabAccessMaster, null: true #TODO: was false, check schema - t.integer :group_id #TODO: check why group/user id missing from CE - t.integer :user_id - t.timestamps null: false - end - create_table :protected_tag_push_access_levels do |t| t.references :protected_tag, index: { name: "index_protected_tag_push_access" }, foreign_key: true, null: false - t.integer :access_level, default: GitlabAccessMaster, null: true #TODO: was false, check schema - t.integer :group_id - t.integer :user_id + t.integer :access_level, default: GITLAB_ACCESS_MASTER, null: true + t.references :user, foreign_key: true, index: true + t.integer :group_id#TODO: Should this have an index? Doesn't appear in brances #, index: true t.timestamps null: false end - #TODO: These had rubocop set to disable Migration/AddConcurrentForeignKey - # add_foreign_key :protected_tag_merge_access_levels, :namespaces, column: :group_id - # add_foreign_key :protected_tag_push_access_levels, :namespaces, column: :group_id + add_foreign_key :protected_tag_push_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey end end diff --git a/db/schema.rb b/db/schema.rb index 05b28b6a63b..650b18bb013 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170317203554) do +ActiveRecord::Schema.define(version: 20170315194013) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -963,28 +963,23 @@ ActiveRecord::Schema.define(version: 20170317203554) do add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree - create_table "protected_tag_merge_access_levels", force: :cascade do |t| - t.integer "protected_tag_id", null: false - t.integer "access_level", default: 40, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - add_index "protected_tag_merge_access_levels", ["protected_tag_id"], name: "index_protected_tag_merge_access", using: :btree - create_table "protected_tag_push_access_levels", force: :cascade do |t| t.integer "protected_tag_id", null: false - t.integer "access_level", default: 40, null: false + t.integer "access_level", default: 40 + t.integer "user_id" + t.integer "group_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false end add_index "protected_tag_push_access_levels", ["protected_tag_id"], name: "index_protected_tag_push_access", using: :btree + add_index "protected_tag_push_access_levels", ["user_id"], name: "index_protected_tag_push_access_levels_on_user_id", using: :btree create_table "protected_tags", force: :cascade do |t| t.integer "project_id", null: false t.string "name", null: false - t.string "timestamps" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end add_index "protected_tags", ["project_id"], name: "index_protected_tags_on_project_id", using: :btree @@ -1331,8 +1326,9 @@ ActiveRecord::Schema.define(version: 20170317203554) do add_foreign_key "project_statistics", "projects", on_delete: :cascade add_foreign_key "protected_branch_merge_access_levels", "protected_branches" add_foreign_key "protected_branch_push_access_levels", "protected_branches" - add_foreign_key "protected_tag_merge_access_levels", "protected_tags" + add_foreign_key "protected_tag_push_access_levels", "namespaces", column: "group_id" add_foreign_key "protected_tag_push_access_levels", "protected_tags" + add_foreign_key "protected_tag_push_access_levels", "users" add_foreign_key "subscriptions", "projects", on_delete: :cascade add_foreign_key "timelogs", "issues", name: "fk_timelogs_issues_issue_id", on_delete: :cascade add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade -- cgit v1.2.3 From 9543025e88d3d0fe298e95330b8d38802da50cc6 Mon Sep 17 00:00:00 2001 From: Adam Niedzielski Date: Mon, 3 Apr 2017 15:17:04 +0200 Subject: Introduce "polling_interval_multiplier" as application setting Implement module for setting "Poll-Interval" response header. Return 429 in ETag caching middleware when polling is disabled. --- ..._interval_multiplier_to_application_settings.rb | 33 ++++++++++++++++++++++ db/schema.rb | 3 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170329124448_add_polling_interval_multiplier_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170329124448_add_polling_interval_multiplier_to_application_settings.rb b/db/migrate/20170329124448_add_polling_interval_multiplier_to_application_settings.rb new file mode 100644 index 00000000000..a8affd19a0b --- /dev/null +++ b/db/migrate/20170329124448_add_polling_interval_multiplier_to_application_settings.rb @@ -0,0 +1,33 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddPollingIntervalMultiplierToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + def up + add_column_with_default :application_settings, :polling_interval_multiplier, :decimal, default: 1, allow_null: false + end + + def down + remove_column :application_settings, :polling_interval_multiplier + end +end diff --git a/db/schema.rb b/db/schema.rb index dba242548c1..19aca4b941e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170317203554) do +ActiveRecord::Schema.define(version: 20170329124448) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -115,6 +115,7 @@ ActiveRecord::Schema.define(version: 20170317203554) do t.integer "unique_ips_limit_per_user" t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false + t.decimal "polling_interval_multiplier", default: 1.0, null: false end create_table "audit_events", force: :cascade do |t| -- cgit v1.2.3 From 5f7cb26394921535a6e1e15f3baee7666c3ef654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 23 Mar 2017 17:23:51 +0100 Subject: Fix the AbuseReport seeder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/fixtures/development/18_abuse_reports.rb | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb index 8618d10387a..7e67262b59e 100644 --- a/db/fixtures/development/18_abuse_reports.rb +++ b/db/fixtures/development/18_abuse_reports.rb @@ -1,5 +1,25 @@ -require 'factory_girl_rails' +module Db + module Fixtures + class Development + def self.seed + Gitlab::Seeder.quiet do + (AbuseReport.default_per_page + 3).times do + reported_user = + User.create!( + username: FFaker::Internet.user_name, + name: FFaker::Name.name, + email: FFaker::Internet.email, + confirmed_at: DateTime.now, + password: '12345678' + ) -(AbuseReport.default_per_page + 3).times do - FactoryGirl.create(:abuse_report) + AbuseReport.create(reporter: User.take, user: reported_user, message: 'User sends spam') + print '.' + end + end + end + end + end end + +Db::Fixtures::Development.seed -- cgit v1.2.3 From 58fe40fbd38dce5d42f5f36681780579fb3f031b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 24 Mar 2017 19:12:22 +0100 Subject: Don't use FFaker in factories, use sequences instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/fixtures/development/18_abuse_reports.rb | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'db') diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb index 7e67262b59e..762fab5f0ab 100644 --- a/db/fixtures/development/18_abuse_reports.rb +++ b/db/fixtures/development/18_abuse_reports.rb @@ -1,20 +1,22 @@ module Db module Fixtures - class Development - def self.seed - Gitlab::Seeder.quiet do - (AbuseReport.default_per_page + 3).times do - reported_user = - User.create!( - username: FFaker::Internet.user_name, - name: FFaker::Name.name, - email: FFaker::Internet.email, - confirmed_at: DateTime.now, - password: '12345678' - ) + module Development + class AbuseReport + def self.seed + Gitlab::Seeder.quiet do + (::AbuseReport.default_per_page + 3).times do + reported_user = + ::User.create!( + username: FFaker::Internet.user_name, + name: FFaker::Name.name, + email: FFaker::Internet.email, + confirmed_at: DateTime.now, + password: '12345678' + ) - AbuseReport.create(reporter: User.take, user: reported_user, message: 'User sends spam') - print '.' + ::AbuseReport.create(reporter: ::User.take, user: reported_user, message: 'User sends spam') + print '.' + end end end end @@ -22,4 +24,4 @@ module Db end end -Db::Fixtures::Development.seed +Db::Fixtures::Development::AbuseReport.seed -- cgit v1.2.3 From 5388bb1cca501442be05ddf929fae7d1bfcbd1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 3 Apr 2017 18:51:29 +0200 Subject: Ensure the AbuseReport fixtures create unique reported users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/fixtures/development/18_abuse_reports.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb index 762fab5f0ab..a3d33706d8e 100644 --- a/db/fixtures/development/18_abuse_reports.rb +++ b/db/fixtures/development/18_abuse_reports.rb @@ -7,7 +7,7 @@ module Db (::AbuseReport.default_per_page + 3).times do reported_user = ::User.create!( - username: FFaker::Internet.user_name, + username: "#{FFaker::Internet.user_name}-reported", name: FFaker::Name.name, email: FFaker::Internet.email, confirmed_at: DateTime.now, -- cgit v1.2.3 From e3f88e689fc5c973f4b08f7d5c80e85d0795b961 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Tue, 4 Apr 2017 09:41:43 +1100 Subject: Remove index for users.current sign in at --- ...18_remove_index_for_users_current_sign_in_at.rb | 25 ++++++++++++++++++++++ db/schema.rb | 3 +-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb (limited to 'db') diff --git a/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb new file mode 100644 index 00000000000..8316ee9eb9f --- /dev/null +++ b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb @@ -0,0 +1,25 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RemoveIndexForUsersCurrentSignInAt < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + if index_exists? :users, :current_sign_in_at + if Gitlab::Database.postgresql? + execute 'DROP INDEX CONCURRENTLY index_users_on_current_sign_in_at;' + else + remove_index :users, :current_sign_in_at + end + end + end + + def down + add_concurrent_index :users, :current_sign_in_at + end +end diff --git a/db/schema.rb b/db/schema.rb index 19aca4b941e..ccf18d07179 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: 20170329124448) do +ActiveRecord::Schema.define(version: 20170402231018) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1252,7 +1252,6 @@ ActiveRecord::Schema.define(version: 20170329124448) do add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree add_index "users", ["created_at"], name: "index_users_on_created_at", using: :btree - 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 -- cgit v1.2.3 From 07d7d8e65905a39164b63f55eccdcea8f10f5d14 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Tue, 4 Apr 2017 03:37:22 +0100 Subject: Renamed ProtectedTag push_access_levels to create_access_levels --- db/migrate/20170309173138_create_protected_tags.rb | 8 ++++---- db/schema.rb | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'db') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb index 00794529143..538f28479c7 100644 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -15,14 +15,14 @@ class CreateProtectedTags < ActiveRecord::Migration add_index :protected_tags, :project_id - create_table :protected_tag_push_access_levels do |t| - t.references :protected_tag, index: { name: "index_protected_tag_push_access" }, foreign_key: true, null: false + create_table :protected_tag_create_access_levels do |t| + t.references :protected_tag, index: { name: "index_protected_tag_create_access" }, foreign_key: true, null: false t.integer :access_level, default: GITLAB_ACCESS_MASTER, null: true t.references :user, foreign_key: true, index: true - t.integer :group_id#TODO: Should this have an index? Doesn't appear in brances #, index: true + t.integer :group_id t.timestamps null: false end - add_foreign_key :protected_tag_push_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey + add_foreign_key :protected_tag_create_access_levels, :namespaces, column: :group_id # rubocop: disable Migration/AddConcurrentForeignKey end end diff --git a/db/schema.rb b/db/schema.rb index 650b18bb013..2a070583834 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -963,7 +963,7 @@ ActiveRecord::Schema.define(version: 20170315194013) do add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree - create_table "protected_tag_push_access_levels", force: :cascade do |t| + create_table "protected_tag_create_access_levels", force: :cascade do |t| t.integer "protected_tag_id", null: false t.integer "access_level", default: 40 t.integer "user_id" @@ -972,8 +972,8 @@ ActiveRecord::Schema.define(version: 20170315194013) do t.datetime "updated_at", null: false end - add_index "protected_tag_push_access_levels", ["protected_tag_id"], name: "index_protected_tag_push_access", using: :btree - add_index "protected_tag_push_access_levels", ["user_id"], name: "index_protected_tag_push_access_levels_on_user_id", using: :btree + add_index "protected_tag_create_access_levels", ["protected_tag_id"], name: "index_protected_tag_create_access", using: :btree + add_index "protected_tag_create_access_levels", ["user_id"], name: "index_protected_tag_create_access_levels_on_user_id", using: :btree create_table "protected_tags", force: :cascade do |t| t.integer "project_id", null: false @@ -1326,9 +1326,9 @@ ActiveRecord::Schema.define(version: 20170315194013) do add_foreign_key "project_statistics", "projects", on_delete: :cascade add_foreign_key "protected_branch_merge_access_levels", "protected_branches" add_foreign_key "protected_branch_push_access_levels", "protected_branches" - add_foreign_key "protected_tag_push_access_levels", "namespaces", column: "group_id" - add_foreign_key "protected_tag_push_access_levels", "protected_tags" - add_foreign_key "protected_tag_push_access_levels", "users" + add_foreign_key "protected_tag_create_access_levels", "namespaces", column: "group_id" + add_foreign_key "protected_tag_create_access_levels", "protected_tags" + add_foreign_key "protected_tag_create_access_levels", "users" add_foreign_key "subscriptions", "projects", on_delete: :cascade add_foreign_key "timelogs", "issues", name: "fk_timelogs_issues_issue_id", on_delete: :cascade add_foreign_key "timelogs", "merge_requests", name: "fk_timelogs_merge_requests_merge_request_id", on_delete: :cascade -- cgit v1.2.3 From d7e3fadb42e00f680034a70735bcea21b9f74dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 4 Apr 2017 08:48:49 +0200 Subject: Ensure we generate unique usernames otherwise validations fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/fixtures/development/18_abuse_reports.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb index a3d33706d8e..88d2f784852 100644 --- a/db/fixtures/development/18_abuse_reports.rb +++ b/db/fixtures/development/18_abuse_reports.rb @@ -4,10 +4,10 @@ module Db class AbuseReport def self.seed Gitlab::Seeder.quiet do - (::AbuseReport.default_per_page + 3).times do + (::AbuseReport.default_per_page + 3).times do |i| reported_user = ::User.create!( - username: "#{FFaker::Internet.user_name}-reported", + username: "reported_user_#{i}", name: FFaker::Name.name, email: FFaker::Internet.email, confirmed_at: DateTime.now, -- cgit v1.2.3 From 267cd3e3594dcb1555b5018723f3cc620873499d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Wed, 15 Feb 2017 23:08:30 -0300 Subject: Incorporate Gitaly client for refs service --- db/migrate/20140502125220_migrate_repo_size.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb index 66203486d53..f5d5d834307 100644 --- a/db/migrate/20140502125220_migrate_repo_size.rb +++ b/db/migrate/20140502125220_migrate_repo_size.rb @@ -8,11 +8,10 @@ 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['path'] - path = File.join(repos_path, namespace_path, project['project_path'] + '.git') + path = File.join(namespace_path, project['project_path'] + '.git') begin - repo = Gitlab::Git::Repository.new(path) + repo = Gitlab::Git::Repository.new('default', path) if repo.empty? print '-' else -- cgit v1.2.3 From c81ef3041e50411166620a99e6ac80f9dc97d86e Mon Sep 17 00:00:00 2001 From: Rydkin Maxim Date: Mon, 20 Feb 2017 01:17:24 +0300 Subject: add auto-cancel for pending pipelines on branch, if they are not HEAD fix changelog MR reference add non-HEAD builds finder and add `created` pipelines to scope add spec for auto-cancel non-HEAD pipelines and refactor create_pipeline_service_spec more refactoring for spec adds option for auto-cancel into CI/CD settings fix spec to new configuration fix rubocop fix schema.rb fix schema.rb replace Gitlab 9.0 with 9.1 in doc change wording on pipeline settings added auto_canceled_by field as identifier of autocancel subject remove unnecessary index replace service with retry_lock replace auto_cancel_pending_pipelines boolean setting with integer (and enum in model) fix schema.rb fix schema.rb remove projekt attribute and clean up spec clean up spec withcouple of shared examples added spec for "It does not cancel current pipeline" scenario add some specs to auto-cancel add spec for another branch pipelines --- ...add_auto_cancel_pending_pipelines_to_project.rb | 33 ++++++++++++++++++++++ ...70312114329_add_auto_canceled_by_to_pipeline.rb | 29 +++++++++++++++++++ db/schema.rb | 6 ++-- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb create mode 100644 db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb (limited to 'db') diff --git a/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb b/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb new file mode 100644 index 00000000000..48ee9268dea --- /dev/null +++ b/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb @@ -0,0 +1,33 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddAutoCancelPendingPipelinesToProject < 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 = 'Creating column with default value' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + def up + add_column_with_default(:projects, :auto_cancel_pending_pipelines, :integer, default: 0) + end + + def down + remove_column(:projects, :auto_cancel_pending_pipelines) + end +end diff --git a/db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb new file mode 100644 index 00000000000..344b83fa253 --- /dev/null +++ b/db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.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 AddAutoCanceledByToPipeline < 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 :ci_commits, :auto_canceled_by, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index ccf18d07179..3ec5b08ac40 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -251,6 +251,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.integer "duration" t.integer "user_id" t.integer "lock_version" + t.integer "auto_canceled_by" end add_index "ci_pipelines", ["project_id", "ref", "status"], name: "index_ci_pipelines_on_project_id_and_ref_and_status", using: :btree @@ -687,8 +688,8 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.string "avatar" t.boolean "share_with_group_lock", default: false t.integer "visibility_level", default: 20, null: false - t.boolean "request_access_enabled", default: false, null: false t.datetime "deleted_at" + t.boolean "request_access_enabled", default: false, null: false t.text "description_html" t.boolean "lfs_enabled" t.integer "parent_id" @@ -920,6 +921,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do 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 + t.integer "auto_cancel_pending_pipelines", default: 0, null: false end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree @@ -1239,9 +1241,9 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.boolean "hide_project_limit", default: false t.string "unlock_token" t.datetime "otp_grace_period_started_at" + t.string "incoming_email_token" t.boolean "ldap_email", default: false, null: false t.boolean "external", default: false - t.string "incoming_email_token" t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" -- cgit v1.2.3 From a4d08e6babbbdbd44267aebdcccd2cc2c63e48ed Mon Sep 17 00:00:00 2001 From: Rydkin Maxim Date: Sat, 18 Mar 2017 14:46:56 +0300 Subject: rename `auto_canceled_by` and add foreign key --- ...12114329_add_auto_canceled_by_id_to_pipeline.rb | 35 ++++++++++++++++++++++ ...70312114329_add_auto_canceled_by_to_pipeline.rb | 29 ------------------ db/schema.rb | 19 ++++++------ 3 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb delete mode 100644 db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb (limited to 'db') diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb new file mode 100644 index 00000000000..5549a4199b2 --- /dev/null +++ b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb @@ -0,0 +1,35 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddAutoCanceledByIdToPipeline < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + def up + add_column :ci_pipelines, :auto_canceled_by_id, :integer + add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: 'set null' + end + + def down + remove_foreign_key :ci_pipelines, column: :auto_canceled_by_id + remove_column :ci_pipelines, :auto_canceled_by_id + end +end diff --git a/db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb deleted file mode 100644 index 344b83fa253..00000000000 --- a/db/migrate/20170312114329_add_auto_canceled_by_to_pipeline.rb +++ /dev/null @@ -1,29 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddAutoCanceledByToPipeline < 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 :ci_commits, :auto_canceled_by, :integer - end -end diff --git a/db/schema.rb b/db/schema.rb index 3ec5b08ac40..9481250e81d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,7 +61,6 @@ ActiveRecord::Schema.define(version: 20170402231018) 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 @@ -99,17 +98,18 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.text "help_page_text_html" t.text "shared_runners_text_html" t.text "after_sign_up_text_html" + t.boolean "sidekiq_throttling_enabled", default: false + t.string "sidekiq_throttling_queues" + t.decimal "sidekiq_throttling_factor" t.boolean "housekeeping_enabled", default: true, null: false t.boolean "housekeeping_bitmaps_enabled", default: true, null: false t.integer "housekeeping_incremental_repack_period", default: 10, null: false t.integer "housekeeping_full_repack_period", default: 50, null: false t.integer "housekeeping_gc_period", default: 200, null: false - t.boolean "sidekiq_throttling_enabled", default: false - t.string "sidekiq_throttling_queues" - t.decimal "sidekiq_throttling_factor" 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" @@ -251,7 +251,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.integer "duration" t.integer "user_id" t.integer "lock_version" - t.integer "auto_canceled_by" + t.integer "auto_canceled_by_id" end add_index "ci_pipelines", ["project_id", "ref", "status"], name: "index_ci_pipelines_on_project_id_and_ref_and_status", using: :btree @@ -688,10 +688,10 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.string "avatar" t.boolean "share_with_group_lock", default: false t.integer "visibility_level", default: 20, null: false - t.datetime "deleted_at" t.boolean "request_access_enabled", default: false, null: false - t.text "description_html" + t.datetime "deleted_at" t.boolean "lfs_enabled" + t.text "description_html" t.integer "parent_id" end @@ -920,8 +920,8 @@ ActiveRecord::Schema.define(version: 20170402231018) 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 t.integer "auto_cancel_pending_pipelines", default: 0, null: false + 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 @@ -1241,10 +1241,10 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.boolean "hide_project_limit", default: false t.string "unlock_token" t.datetime "otp_grace_period_started_at" - t.string "incoming_email_token" t.boolean "ldap_email", default: false, null: false t.boolean "external", default: false t.string "organization" + t.string "incoming_email_token" t.boolean "authorized_projects_populated" t.boolean "ghost" t.boolean "notified_of_own_activity" @@ -1299,6 +1299,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade + add_foreign_key "ci_pipelines", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_262d4c2d19", on_delete: :nullify 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 -- cgit v1.2.3 From effcbaf372001b238741fa1174dad588ef190b61 Mon Sep 17 00:00:00 2001 From: Rydkin Maxim Date: Sat, 18 Mar 2017 16:44:38 +0300 Subject: fix on_delete --- db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb index 5549a4199b2..5156860586a 100644 --- a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb +++ b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb @@ -25,7 +25,7 @@ class AddAutoCanceledByIdToPipeline < ActiveRecord::Migration def up add_column :ci_pipelines, :auto_canceled_by_id, :integer - add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: 'set null' + add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: :nullify end def down -- cgit v1.2.3 From 4f748f74bc561ed6cc37f2c57077e72c0cda8c9a Mon Sep 17 00:00:00 2001 From: Rydkin Maxim Date: Tue, 21 Mar 2017 00:48:05 +0300 Subject: replace on_delete in migration with database type related expression --- db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb index 5156860586a..46dab852fcf 100644 --- a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb +++ b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb @@ -24,8 +24,15 @@ class AddAutoCanceledByIdToPipeline < ActiveRecord::Migration disable_ddl_transaction! def up + on_delete = + if Database.mysql? + :nullify + else + 'SET NULL' + end + add_column :ci_pipelines, :auto_canceled_by_id, :integer - add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: :nullify + add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete end def down -- cgit v1.2.3 From a0de26f2c439554feb446c5283c07ea90279304c Mon Sep 17 00:00:00 2001 From: Rydkin Maxim Date: Tue, 21 Mar 2017 09:30:23 +0300 Subject: fix migration error --- db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb index 46dab852fcf..6e89967e4be 100644 --- a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb +++ b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb @@ -25,7 +25,7 @@ class AddAutoCanceledByIdToPipeline < ActiveRecord::Migration def up on_delete = - if Database.mysql? + if Gitlab::Database.mysql? :nullify else 'SET NULL' -- cgit v1.2.3 From b9f7d4b45e0456c35d8e95977bb2f9281cde69b4 Mon Sep 17 00:00:00 2001 From: Rydkin Maxim Date: Tue, 28 Mar 2017 21:01:28 +0300 Subject: split up migrations --- ...12114329_add_auto_canceled_by_id_to_pipeline.rb | 17 ++------- ..._auto_canceled_by_id_foreign_key_to_pipeline.rb | 40 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb (limited to 'db') diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb index 6e89967e4be..813813225e0 100644 --- a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb +++ b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb @@ -21,22 +21,9 @@ class AddAutoCanceledByIdToPipeline < ActiveRecord::Migration # # To disable transactions uncomment the following line and remove these # comments: - disable_ddl_transaction! - - def up - on_delete = - if Gitlab::Database.mysql? - :nullify - else - 'SET NULL' - end + # disable_ddl_transaction! + def change add_column :ci_pipelines, :auto_canceled_by_id, :integer - add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete - end - - def down - remove_foreign_key :ci_pipelines, column: :auto_canceled_by_id - remove_column :ci_pipelines, :auto_canceled_by_id end end diff --git a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb new file mode 100644 index 00000000000..c9dd5be9799 --- /dev/null +++ b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb @@ -0,0 +1,40 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddAutoCanceledByIdForeignKeyToPipeline < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + disable_ddl_transaction! + + def up + on_delete = + if Gitlab::Database.mysql? + :nullify + else + 'SET NULL' + end + + add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete + end + + def down + remove_foreign_key :ci_pipelines, column: :auto_canceled_by_id + end +end -- cgit v1.2.3 From 7f8e0bce5ab3af7be049a9d2887e611667598d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 5 Apr 2017 11:04:34 +0000 Subject: Added mock deployment and monitoring service with environments fixtures --- db/fixtures/development/19_environments.rb | 70 +++++++++++++++++++++++++++++ db/fixtures/development/19_nested_groups.rb | 69 ---------------------------- db/fixtures/development/20_nested_groups.rb | 69 ++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 69 deletions(-) create mode 100644 db/fixtures/development/19_environments.rb delete mode 100644 db/fixtures/development/19_nested_groups.rb create mode 100644 db/fixtures/development/20_nested_groups.rb (limited to 'db') diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb new file mode 100644 index 00000000000..93214b9d3e7 --- /dev/null +++ b/db/fixtures/development/19_environments.rb @@ -0,0 +1,70 @@ +require './spec/support/sidekiq' + +class Gitlab::Seeder::Environments + def initialize(project) + @project = project + end + + def seed! + @project.create_mock_deployment_service!(active: true) + @project.create_mock_monitoring_service!(active: true) + + create_master_deployments!('production') + create_master_deployments!('staging') + create_merge_request_review_deployments! + end + + private + + def create_master_deployments!(name) + @project.repository.commits('master', limit: 4).map do |commit| + create_deployment!( + @project, + name, + 'master', + commit.id + ) + end + end + + def create_merge_request_review_deployments! + @project.merge_requests.sample(4).map do |merge_request| + next unless merge_request.diff_head_sha + + create_deployment!( + merge_request.source_project, + "review/#{merge_request.source_branch}", + merge_request.source_branch, + merge_request.diff_head_sha + ) + end + end + + def create_deployment!(project, name, ref, sha) + environment = find_or_create_environment!(project, name) + environment.deployments.create!( + project: project, + ref: ref, + sha: sha, + tag: false, + deployable: find_deployable(project, name) + ) + end + + def find_or_create_environment!(project, name) + project.environments.find_or_create_by!(name: name).tap do |environment| + environment.update(external_url: "https://google.com/#{name}") + end + end + + def find_deployable(project, environment) + project.builds.where(environment: environment).sample + end +end + +Gitlab::Seeder.quiet do + Project.all.sample(5).each do |project| + project_environments = Gitlab::Seeder::Environments.new(project) + project_environments.seed! + end +end diff --git a/db/fixtures/development/19_nested_groups.rb b/db/fixtures/development/19_nested_groups.rb deleted file mode 100644 index d8dddc3fee9..00000000000 --- a/db/fixtures/development/19_nested_groups.rb +++ /dev/null @@ -1,69 +0,0 @@ -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 diff --git a/db/fixtures/development/20_nested_groups.rb b/db/fixtures/development/20_nested_groups.rb new file mode 100644 index 00000000000..d8dddc3fee9 --- /dev/null +++ b/db/fixtures/development/20_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 1e54181523f42c2734056b6ea548ebc2134f57a6 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 5 Apr 2017 15:12:29 +0200 Subject: Improve migration for container repositories table --- db/migrate/20170322013926_create_container_repository.rb | 9 +++++++-- db/schema.rb | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/migrate/20170322013926_create_container_repository.rb b/db/migrate/20170322013926_create_container_repository.rb index 87a1523724c..32eba3903b1 100644 --- a/db/migrate/20170322013926_create_container_repository.rb +++ b/db/migrate/20170322013926_create_container_repository.rb @@ -5,8 +5,13 @@ class CreateContainerRepository < ActiveRecord::Migration def change create_table :container_repositories do |t| - t.integer :project_id - t.string :name + t.references :project, foreign_key: true, null: false + t.string :name, null: false + + t.timestamps null: false end + + add_index :container_repositories, :project_id + add_index :container_repositories, [:project_id, :name], unique: true end end diff --git a/db/schema.rb b/db/schema.rb index 3c11e68da2c..9ee1d0e6aef 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -324,10 +324,15 @@ ActiveRecord::Schema.define(version: 20170329124448) do add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree create_table "container_repositories", force: :cascade do |t| - t.integer "project_id" - t.string "name" + t.integer "project_id", null: false + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end + add_index "container_repositories", ["project_id", "name"], name: "index_container_repositories_on_project_id_and_name", unique: true, using: :btree + add_index "container_repositories", ["project_id"], name: "index_container_repositories_on_project_id", using: :btree + create_table "deploy_keys_projects", force: :cascade do |t| t.integer "deploy_key_id", null: false t.integer "project_id", null: false @@ -1304,6 +1309,7 @@ ActiveRecord::Schema.define(version: 20170329124448) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade + add_foreign_key "container_repositories", "projects" add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade add_foreign_key "label_priorities", "projects", on_delete: :cascade -- cgit v1.2.3 From 58371efbb0bd051d3a82f82acac98ad4692efeb4 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 24 Mar 2017 12:08:34 +0100 Subject: Periodically mark projects that are stuck in importing as failed Adds import jid to projects Refactor middleware to set custom expiration time via sidekiq options Add completed_jids option to sidekiq status and a few other changes --- db/migrate/20170324110346_add_import_jid_to_projects.rb | 9 +++++++++ db/schema.rb | 1 + 2 files changed, 10 insertions(+) create mode 100644 db/migrate/20170324110346_add_import_jid_to_projects.rb (limited to 'db') diff --git a/db/migrate/20170324110346_add_import_jid_to_projects.rb b/db/migrate/20170324110346_add_import_jid_to_projects.rb new file mode 100644 index 00000000000..55b87b9d56d --- /dev/null +++ b/db/migrate/20170324110346_add_import_jid_to_projects.rb @@ -0,0 +1,9 @@ +class AddImportJidToProjects < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :projects, :import_jid, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index ccf18d07179..76f6a511561 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -920,6 +920,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do 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 + t.string "import_jid" end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree -- cgit v1.2.3 From 189da6b4df2853adcbf66ea0004b23d6788cc3c3 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Tue, 4 Apr 2017 16:27:23 +0000 Subject: attempt to fix db failure --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 76f6a511561..0ab4a4eabef 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: 20170402231018) do +ActiveRecord::Schema.define(version: 20170324110346) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 7c9a46bc3e9b4ce5bb9ba5ab287176e34ed0a0c6 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 5 Apr 2017 06:28:43 +0000 Subject: Revert schema.rb --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 0ab4a4eabef..76f6a511561 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: 20170324110346) do +ActiveRecord::Schema.define(version: 20170402231018) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 0bd4c17ee6480e88e05bb1a614c0d88819a37c74 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 5 Apr 2017 10:13:21 +0200 Subject: attempt to fix migration --- db/migrate/20170324110346_add_import_jid_to_projects.rb | 9 --------- db/migrate/20170405080720_add_import_jid_to_projects.rb | 9 +++++++++ db/schema.rb | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 db/migrate/20170324110346_add_import_jid_to_projects.rb create mode 100644 db/migrate/20170405080720_add_import_jid_to_projects.rb (limited to 'db') diff --git a/db/migrate/20170324110346_add_import_jid_to_projects.rb b/db/migrate/20170324110346_add_import_jid_to_projects.rb deleted file mode 100644 index 55b87b9d56d..00000000000 --- a/db/migrate/20170324110346_add_import_jid_to_projects.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddImportJidToProjects < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :projects, :import_jid, :string - end -end diff --git a/db/migrate/20170405080720_add_import_jid_to_projects.rb b/db/migrate/20170405080720_add_import_jid_to_projects.rb new file mode 100644 index 00000000000..55b87b9d56d --- /dev/null +++ b/db/migrate/20170405080720_add_import_jid_to_projects.rb @@ -0,0 +1,9 @@ +class AddImportJidToProjects < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :projects, :import_jid, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 76f6a511561..582f68cbee7 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: 20170402231018) do +ActiveRecord::Schema.define(version: 20170405080720) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 44ec40028c60b4f3a5d3f1bb049996f4d2caf9af Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 5 Apr 2017 16:59:28 +0200 Subject: fix project authorizations migration issue --- db/migrate/20170130204620_add_index_to_project_authorizations.rb | 4 +++- 1 file changed, 3 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 629b49436e3..8c593c39440 100644 --- a/db/migrate/20170130204620_add_index_to_project_authorizations.rb +++ b/db/migrate/20170130204620_add_index_to_project_authorizations.rb @@ -6,7 +6,9 @@ class AddIndexToProjectAuthorizations < ActiveRecord::Migration disable_ddl_transaction! def up - add_concurrent_index(:project_authorizations, :project_id) + unless index_exists?(:project_authorizations, :project_id) + add_concurrent_index(:project_authorizations, :project_id) + end end def down -- cgit v1.2.3 From 08bbb9fce66cb46d3262e6cd4c4379b59f065be0 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 9 Mar 2017 19:29:11 -0600 Subject: Add option to start a new discussion on an MR --- ...reply_to_discussion_id_to_sent_notifications.rb | 29 ++++++++++++++++++++++ ...217_add_index_to_note_original_discussion_id.rb | 18 ++++++++++++++ db/schema.rb | 2 ++ 3 files changed, 49 insertions(+) create mode 100644 db/migrate/20161128095517_add_in_reply_to_discussion_id_to_sent_notifications.rb create mode 100644 db/migrate/20170308220217_add_index_to_note_original_discussion_id.rb (limited to 'db') diff --git a/db/migrate/20161128095517_add_in_reply_to_discussion_id_to_sent_notifications.rb b/db/migrate/20161128095517_add_in_reply_to_discussion_id_to_sent_notifications.rb new file mode 100644 index 00000000000..d56d83ca1d3 --- /dev/null +++ b/db/migrate/20161128095517_add_in_reply_to_discussion_id_to_sent_notifications.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 AddInReplyToDiscussionIdToSentNotifications < 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 :sent_notifications, :in_reply_to_discussion_id, :string + end +end diff --git a/db/migrate/20170308220217_add_index_to_note_original_discussion_id.rb b/db/migrate/20170308220217_add_index_to_note_original_discussion_id.rb new file mode 100644 index 00000000000..2c823ed84a9 --- /dev/null +++ b/db/migrate/20170308220217_add_index_to_note_original_discussion_id.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 AddIndexToNoteOriginalDiscussionId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :notes, :original_discussion_id + end + + def down + remove_index :notes, :original_discussion_id if index_exists? :notes, :original_discussion_id + end +end diff --git a/db/schema.rb b/db/schema.rb index ccf18d07179..1b23bab5af2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -736,6 +736,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do add_index "notes", ["note"], name: "index_notes_on_note_trigram", using: :gin, opclasses: {"note"=>"gin_trgm_ops"} add_index "notes", ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree + add_index "notes", ["original_discussion_id"], name: "index_notes_on_original_discussion_id", using: :btree add_index "notes", ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type", using: :btree add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree @@ -999,6 +1000,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.string "line_code" t.string "note_type" t.text "position" + t.string "in_reply_to_discussion_id" end add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree -- cgit v1.2.3 From c319f2114177f011cd0c6c23b04f7c19971268bf Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 4 Apr 2017 17:27:23 -0500 Subject: Address review comments --- ...8220217_add_index_to_note_original_discussion_id.rb | 18 ------------------ db/schema.rb | 1 - 2 files changed, 19 deletions(-) delete mode 100644 db/migrate/20170308220217_add_index_to_note_original_discussion_id.rb (limited to 'db') diff --git a/db/migrate/20170308220217_add_index_to_note_original_discussion_id.rb b/db/migrate/20170308220217_add_index_to_note_original_discussion_id.rb deleted file mode 100644 index 2c823ed84a9..00000000000 --- a/db/migrate/20170308220217_add_index_to_note_original_discussion_id.rb +++ /dev/null @@ -1,18 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class AddIndexToNoteOriginalDiscussionId < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - def up - add_concurrent_index :notes, :original_discussion_id - end - - def down - remove_index :notes, :original_discussion_id if index_exists? :notes, :original_discussion_id - end -end diff --git a/db/schema.rb b/db/schema.rb index 1b23bab5af2..af7dc07d5ba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -736,7 +736,6 @@ ActiveRecord::Schema.define(version: 20170402231018) do add_index "notes", ["note"], name: "index_notes_on_note_trigram", using: :gin, opclasses: {"note"=>"gin_trgm_ops"} add_index "notes", ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree - add_index "notes", ["original_discussion_id"], name: "index_notes_on_original_discussion_id", using: :btree add_index "notes", ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type", using: :btree add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree -- cgit v1.2.3 From 63c7801e459d7a7c3ca5a1222496b8cc188d9258 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 4 Apr 2017 17:41:04 -0500 Subject: Remove and ignore notes.original_discussion_id column --- ...04170532_remove_notes_original_discussion_id.rb | 23 ++++++++++++++++++++++ db/schema.rb | 3 +-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 db/post_migrate/20170404170532_remove_notes_original_discussion_id.rb (limited to 'db') diff --git a/db/post_migrate/20170404170532_remove_notes_original_discussion_id.rb b/db/post_migrate/20170404170532_remove_notes_original_discussion_id.rb new file mode 100644 index 00000000000..0c3b3bd5eb3 --- /dev/null +++ b/db/post_migrate/20170404170532_remove_notes_original_discussion_id.rb @@ -0,0 +1,23 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RemoveNotesOriginalDiscussionId < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + # 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 + remove_column :notes, :original_discussion_id, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index af7dc07d5ba..ce65ddaccc9 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: 20170402231018) do +ActiveRecord::Schema.define(version: 20170404170532) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -724,7 +724,6 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.datetime "resolved_at" t.integer "resolved_by_id" t.string "discussion_id" - t.string "original_discussion_id" t.text "note_html" end -- cgit v1.2.3 From 016e1a2906e27f519a3c67d30806a2dc5cb110b5 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 5 Apr 2017 17:24:44 +0000 Subject: Restore schema --- db/schema.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 9481250e81d..a7efdcbe111 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,6 +61,7 @@ ActiveRecord::Schema.define(version: 20170402231018) 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 @@ -98,18 +99,17 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.text "help_page_text_html" t.text "shared_runners_text_html" t.text "after_sign_up_text_html" - t.boolean "sidekiq_throttling_enabled", default: false - t.string "sidekiq_throttling_queues" - t.decimal "sidekiq_throttling_factor" t.boolean "housekeeping_enabled", default: true, null: false t.boolean "housekeeping_bitmaps_enabled", default: true, null: false t.integer "housekeeping_incremental_repack_period", default: 10, null: false t.integer "housekeeping_full_repack_period", default: 50, null: false t.integer "housekeeping_gc_period", default: 200, null: false + t.boolean "sidekiq_throttling_enabled", default: false + t.string "sidekiq_throttling_queues" + t.decimal "sidekiq_throttling_factor" 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" @@ -690,8 +690,8 @@ ActiveRecord::Schema.define(version: 20170402231018) 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 @@ -1243,8 +1243,8 @@ ActiveRecord::Schema.define(version: 20170402231018) 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 "ghost" t.boolean "notified_of_own_activity" -- cgit v1.2.3 From 9997c58fc0db6469cde1a21428e050aa7b550a9a Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Thu, 6 Apr 2017 09:53:57 +1100 Subject: Add remove_concurrent_index to database helper --- db/migrate/20160615142710_add_index_on_requested_at_to_members.rb | 1 + db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb | 1 + db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb | 1 + db/migrate/20160620115026_add_index_on_runners_locked.rb | 1 + db/migrate/20160715134306_add_index_for_pipeline_user_id.rb | 1 + db/migrate/20160725104020_merge_request_diff_remove_uniq.rb | 1 + db/migrate/20160725104452_merge_request_diff_add_index.rb | 1 + db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb | 1 + db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb | 1 + db/migrate/20160805041956_add_deleted_at_to_namespaces.rb | 1 + db/migrate/20160808085602_add_index_for_build_token.rb | 1 + db/migrate/20160810142633_remove_redundant_indexes.rb | 1 + db/migrate/20160819221631_add_index_to_note_discussion_id.rb | 1 + db/migrate/20160819232256_add_incoming_email_token_to_users.rb | 1 + db/migrate/20160919145149_add_group_id_to_labels.rb | 1 + db/migrate/20160920160832_add_index_to_labels_title.rb | 1 + db/migrate/20161017125927_add_unique_index_to_labels.rb | 1 + db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb | 1 + db/migrate/20161031181638_add_unique_index_to_subscriptions.rb | 1 + db/migrate/20161106185620_add_project_import_data_project_index.rb | 1 + db/migrate/20161124111395_add_index_to_parent_id.rb | 1 + db/migrate/20161128142110_remove_unnecessary_indexes.rb | 1 + db/migrate/20161202152035_add_index_to_routes.rb | 1 + db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb | 1 + db/migrate/20161206153751_add_path_index_to_namespace.rb | 1 + db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb | 1 + db/migrate/20161206153754_add_name_index_to_namespace.rb | 1 + db/migrate/20161207231621_create_environment_name_unique_index.rb | 1 + db/migrate/20161209153400_add_unique_index_for_environment_slug.rb | 1 + db/migrate/20161212142807_add_lower_path_index_to_routes.rb | 1 + ...0170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb | 1 + db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb | 1 + db/migrate/20170130204620_add_index_to_project_authorizations.rb | 1 + db/migrate/20170131221752_add_relative_position_to_issues.rb | 1 + db/migrate/20170204181513_add_index_to_labels_for_type_and_project.rb | 1 + db/migrate/20170210062829_add_index_to_labels_for_title_and_project.rb | 1 + .../20170210075922_add_index_to_ci_trigger_requests_for_commit_id.rb | 1 + db/migrate/20170210103609_add_index_to_user_agent_detail.rb | 1 + db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb | 1 + db/migrate/20170216141440_drop_index_for_builds_project_status.rb | 1 + db/migrate/20170222143500_remove_old_project_id_columns.rb | 1 + db/migrate/20170313213916_add_index_to_user_ghost.rb | 1 + 42 files changed, 42 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 7a8ed99c68f..178e4bf5ed3 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,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexOnRequestedAtToMembers < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb b/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb index 4bb4204cebd..081df23f394 100644 --- a/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb +++ b/db/migrate/20160616103005_remove_keys_fingerprint_index_if_exists.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class RemoveKeysFingerprintIndexIfExists < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb b/db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb index e35af38aac3..76bb6a09639 100644 --- a/db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb +++ b/db/migrate/20160616103948_add_unique_index_to_keys_fingerprint.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddUniqueIndexToKeysFingerprint < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160620115026_add_index_on_runners_locked.rb b/db/migrate/20160620115026_add_index_on_runners_locked.rb index 6ca486c63d1..48f4495b0a4 100644 --- a/db/migrate/20160620115026_add_index_on_runners_locked.rb +++ b/db/migrate/20160620115026_add_index_on_runners_locked.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddIndexOnRunnersLocked < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 a05a4c679e3..fec17ffb7f6 100644 --- a/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb +++ b/db/migrate/20160715134306_add_index_for_pipeline_user_id.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexForPipelineUserId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb index 75a3eb15124..12e11bc3fbe 100644 --- a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb +++ b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class MergeRequestDiffRemoveUniq < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20160725104452_merge_request_diff_add_index.rb b/db/migrate/20160725104452_merge_request_diff_add_index.rb index 6d04242dd25..60d81e0bdc0 100644 --- a/db/migrate/20160725104452_merge_request_diff_add_index.rb +++ b/db/migrate/20160725104452_merge_request_diff_add_index.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class MergeRequestDiffAddIndex < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb b/db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb index 5fd51cb65f1..6d7733762c8 100644 --- a/db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb +++ b/db/migrate/20160802010328_remove_builds_enable_index_on_projects.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class RemoveBuildsEnableIndexOnProjects < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb b/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb index baf2e70b127..9c1511963f7 100644 --- a/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb +++ b/db/migrate/20160803161903_add_unique_index_to_lists_label_id.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddUniqueIndexToListsLabelId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb b/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb index 3f074723b4a..30d98a0124e 100644 --- a/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb +++ b/db/migrate/20160805041956_add_deleted_at_to_namespaces.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddDeletedAtToNamespaces < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160808085602_add_index_for_build_token.rb b/db/migrate/20160808085602_add_index_for_build_token.rb index 6c5d7268e72..0446b2f2e15 100644 --- a/db/migrate/20160808085602_add_index_for_build_token.rb +++ b/db/migrate/20160808085602_add_index_for_build_token.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexForBuildToken < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160810142633_remove_redundant_indexes.rb b/db/migrate/20160810142633_remove_redundant_indexes.rb index 8641c6ffa8f..d7ab022d7bc 100644 --- a/db/migrate/20160810142633_remove_redundant_indexes.rb +++ b/db/migrate/20160810142633_remove_redundant_indexes.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class RemoveRedundantIndexes < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 8f693e97a58..843643c4e95 100644 --- a/db/migrate/20160819221631_add_index_to_note_discussion_id.rb +++ b/db/migrate/20160819221631_add_index_to_note_discussion_id.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddIndexToNoteDiscussionId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 bcad3416d04..a004a3802a2 100644 --- a/db/migrate/20160819232256_add_incoming_email_token_to_users.rb +++ b/db/migrate/20160819232256_add_incoming_email_token_to_users.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddIncomingEmailTokenToUsers < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160919145149_add_group_id_to_labels.rb b/db/migrate/20160919145149_add_group_id_to_labels.rb index e20e693f3aa..917c2b0c521 100644 --- a/db/migrate/20160919145149_add_group_id_to_labels.rb +++ b/db/migrate/20160919145149_add_group_id_to_labels.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddGroupIdToLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20160920160832_add_index_to_labels_title.rb b/db/migrate/20160920160832_add_index_to_labels_title.rb index 19f7b1076a7..e38c655baee 100644 --- a/db/migrate/20160920160832_add_index_to_labels_title.rb +++ b/db/migrate/20160920160832_add_index_to_labels_title.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexToLabelsTitle < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb index f2b56ebfb7b..b8f6a803a0a 100644 --- a/db/migrate/20161017125927_add_unique_index_to_labels.rb +++ b/db/migrate/20161017125927_add_unique_index_to_labels.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddUniqueIndexToLabels < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 35ad22b6c01..b77daf12f68 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 @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb index 4b1b29e1265..f263377fbc6 100644 --- a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb +++ b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddUniqueIndexToSubscriptions < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 94b8ddd46f5..b3746dc4f6c 100644 --- a/db/migrate/20161106185620_add_project_import_data_project_index.rb +++ b/db/migrate/20161106185620_add_project_import_data_project_index.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddProjectImportDataProjectIndex < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161124111395_add_index_to_parent_id.rb b/db/migrate/20161124111395_add_index_to_parent_id.rb index 73f9d92bb22..065643e058d 100644 --- a/db/migrate/20161124111395_add_index_to_parent_id.rb +++ b/db/migrate/20161124111395_add_index_to_parent_id.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddIndexToParentId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161128142110_remove_unnecessary_indexes.rb b/db/migrate/20161128142110_remove_unnecessary_indexes.rb index 8100287ef48..699a9368eb3 100644 --- a/db/migrate/20161128142110_remove_unnecessary_indexes.rb +++ b/db/migrate/20161128142110_remove_unnecessary_indexes.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class RemoveUnnecessaryIndexes < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20161202152035_add_index_to_routes.rb b/db/migrate/20161202152035_add_index_to_routes.rb index 6d6c8906204..552b5fab68c 100644 --- a/db/migrate/20161202152035_add_index_to_routes.rb +++ b/db/migrate/20161202152035_add_index_to_routes.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddIndexToRoutes < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb b/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb index 2977917f2d1..7d39c2ae626 100644 --- a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb +++ b/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class RemoveUniqPathIndexFromNamespace < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161206153751_add_path_index_to_namespace.rb b/db/migrate/20161206153751_add_path_index_to_namespace.rb index b0bac7d121e..623037e35cd 100644 --- a/db/migrate/20161206153751_add_path_index_to_namespace.rb +++ b/db/migrate/20161206153751_add_path_index_to_namespace.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddPathIndexToNamespace < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb b/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb index cc9d4974baa..9296ae36aa5 100644 --- a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb +++ b/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class RemoveUniqNameIndexFromNamespace < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161206153754_add_name_index_to_namespace.rb b/db/migrate/20161206153754_add_name_index_to_namespace.rb index b3f3cb68a99..2bbd039ff27 100644 --- a/db/migrate/20161206153754_add_name_index_to_namespace.rb +++ b/db/migrate/20161206153754_add_name_index_to_namespace.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddNameIndexToNamespace < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb index 5ff0f5bae4d..15093350f12 100644 --- a/db/migrate/20161207231621_create_environment_name_unique_index.rb +++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 ede0316e860..42a90091b87 100644 --- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb +++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 53f4c6bbb18..76db5179795 100644 --- a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb +++ b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddLowerPathIndexToRoutes < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb b/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb index 4ea953f2b78..c006098fafd 100644 --- a/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb +++ b/db/migrate/20170121123724_add_index_to_ci_builds_for_status_runner_id_and_type.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexToCiBuildsForStatusRunnerIdAndType < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb b/db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb index 620befcf4d7..00aa0b311b1 100644 --- a/db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb +++ b/db/migrate/20170121130655_add_index_to_ci_runners_for_is_shared.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexToCiRunnersForIsShared < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20170130204620_add_index_to_project_authorizations.rb b/db/migrate/20170130204620_add_index_to_project_authorizations.rb index 629b49436e3..aded62e08b3 100644 --- a/db/migrate/20170130204620_add_index_to_project_authorizations.rb +++ b/db/migrate/20170130204620_add_index_to_project_authorizations.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexToProjectAuthorizations < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers diff --git a/db/migrate/20170131221752_add_relative_position_to_issues.rb b/db/migrate/20170131221752_add_relative_position_to_issues.rb index 1baad0893e3..fd18d8b6a60 100644 --- a/db/migrate/20170131221752_add_relative_position_to_issues.rb +++ b/db/migrate/20170131221752_add_relative_position_to_issues.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddRelativePositionToIssues < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 31ef458c44f..b1b0a601007 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 @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexToLabelsForTypeAndProject < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 70fb0ef12f9..2c20f6a48ab 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 @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexToLabelsForTitleAndProject < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 07d4f8af27f..c31057f2617 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 @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexToCiTriggerRequestsForCommitId < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 2d8329b7862..ba4976a5ce8 100644 --- a/db/migrate/20170210103609_add_index_to_user_agent_detail.rb +++ b/db/migrate/20170210103609_add_index_to_user_agent_detail.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddIndexToUserAgentDetail < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers 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 8a96a784c97..884c4e569d6 100644 --- a/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb +++ b/db/migrate/20170216135621_add_index_for_latest_successful_pipeline.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class AddIndexForLatestSuccessfulPipeline < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = false 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 a2839f52d89..56ad566ca67 100644 --- a/db/migrate/20170216141440_drop_index_for_builds_project_status.rb +++ b/db/migrate/20170216141440_drop_index_for_builds_project_status.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class DropIndexForBuildsProjectStatus < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = false diff --git a/db/migrate/20170222143500_remove_old_project_id_columns.rb b/db/migrate/20170222143500_remove_old_project_id_columns.rb index eac93e8e407..268144a2552 100644 --- a/db/migrate/20170222143500_remove_old_project_id_columns.rb +++ b/db/migrate/20170222143500_remove_old_project_id_columns.rb @@ -1,3 +1,4 @@ +# rubocop:disable RemoveIndex class RemoveOldProjectIdColumns < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers disable_ddl_transaction! diff --git a/db/migrate/20170313213916_add_index_to_user_ghost.rb b/db/migrate/20170313213916_add_index_to_user_ghost.rb index c429039c275..fe5847ed225 100644 --- a/db/migrate/20170313213916_add_index_to_user_ghost.rb +++ b/db/migrate/20170313213916_add_index_to_user_ghost.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class AddIndexToUserGhost < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers -- cgit v1.2.3 From 4a030326605e2ab2ce7b520d14c6ac3ad020d58b Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 6 Apr 2017 14:41:27 +0800 Subject: Fix rolling back for MySQL --- ...0130204620_add_index_to_project_authorizations.rb | 3 ++- ...3_add_auto_cancel_pending_pipelines_to_project.rb | 18 ------------------ ...0312114329_add_auto_canceled_by_id_to_pipeline.rb | 20 -------------------- ...dd_auto_canceled_by_id_foreign_key_to_pipeline.rb | 18 ------------------ 4 files changed, 2 insertions(+), 57 deletions(-) (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 629b49436e3..0884296131d 100644 --- a/db/migrate/20170130204620_add_index_to_project_authorizations.rb +++ b/db/migrate/20170130204620_add_index_to_project_authorizations.rb @@ -6,7 +6,8 @@ class AddIndexToProjectAuthorizations < ActiveRecord::Migration disable_ddl_transaction! def up - add_concurrent_index(:project_authorizations, :project_id) + add_concurrent_index(:project_authorizations, :project_id) unless + index_exists?(:project_authorizations, :project_id) end def down diff --git a/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb b/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb index 48ee9268dea..aa64f2dddca 100644 --- a/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb +++ b/db/migrate/20170305180853_add_auto_cancel_pending_pipelines_to_project.rb @@ -1,26 +1,8 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddAutoCancelPendingPipelinesToProject < 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 = 'Creating column with default value' - - # When using the methods "add_concurrent_index" or "add_column_with_default" - # you must disable the use of transactions as these methods can not run in an - # existing transaction. When using "add_concurrent_index" make sure that this - # method is the _only_ method called in the migration, any other changes - # should go in a separate migration. This ensures that upon failure _only_ the - # index creation fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: disable_ddl_transaction! def up diff --git a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb index 813813225e0..1690ce90564 100644 --- a/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb +++ b/db/migrate/20170312114329_add_auto_canceled_by_id_to_pipeline.rb @@ -1,28 +1,8 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddAutoCanceledByIdToPipeline < 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 :ci_pipelines, :auto_canceled_by_id, :integer end diff --git a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb index c9dd5be9799..1e7b02ecf0e 100644 --- a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb +++ b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb @@ -1,26 +1,8 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddAutoCanceledByIdForeignKeyToPipeline < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - # Set this constant to true if this migration requires downtime. DOWNTIME = false - # When a migration requires downtime you **must** uncomment the following - # constant and define a short and easy to understand explanation as to why the - # migration requires downtime. - # DOWNTIME_REASON = '' - - # When using the methods "add_concurrent_index" or "add_column_with_default" - # you must disable the use of transactions as these methods can not run in an - # existing transaction. When using "add_concurrent_index" make sure that this - # method is the _only_ method called in the migration, any other changes - # should go in a separate migration. This ensures that upon failure _only_ the - # index creation fails and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: disable_ddl_transaction! def up -- cgit v1.2.3 From a3430f011f1adceaef8484f38a57018712a18ad2 Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Tue, 24 Jan 2017 22:09:58 +0100 Subject: Support 2FA requirement per-group --- ...24193147_add_two_factor_columns_to_namespaces.rb | 21 +++++++++++++++++++++ ...0170124193205_add_two_factor_columns_to_users.rb | 17 +++++++++++++++++ db/schema.rb | 5 +++++ 3 files changed, 43 insertions(+) create mode 100644 db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb create mode 100644 db/migrate/20170124193205_add_two_factor_columns_to_users.rb (limited to 'db') diff --git a/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb b/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb new file mode 100644 index 00000000000..ca4429c676c --- /dev/null +++ b/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb @@ -0,0 +1,21 @@ +class AddTwoFactorColumnsToNamespaces < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:namespaces, :require_two_factor_authentication, :boolean, default: false) + add_column_with_default(:namespaces, :two_factor_grace_period, :integer, default: 48) + + add_concurrent_index(:namespaces, :require_two_factor_authentication) + end + + def down + remove_column(:namespaces, :require_two_factor_authentication) + remove_column(:namespaces, :two_factor_grace_period) + + remove_index(:namespaces, :require_two_factor_authentication) if index_exists?(:namespaces, :require_two_factor_authentication) + end +end diff --git a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb new file mode 100644 index 00000000000..bef1b2062c8 --- /dev/null +++ b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb @@ -0,0 +1,17 @@ +class AddTwoFactorColumnsToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:users, :require_two_factor_authentication, :boolean, default: false) + add_column_with_default(:users, :two_factor_grace_period, :integer, default: 48) + end + + def down + remove_column(:users, :require_two_factor_authentication) + remove_column(:users, :two_factor_grace_period) + end +end diff --git a/db/schema.rb b/db/schema.rb index ccf18d07179..2d2507828d4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -692,6 +692,8 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.text "description_html" t.boolean "lfs_enabled" t.integer "parent_id" + t.boolean "require_two_factor_authentication", default: false, null: false + t.integer "two_factor_grace_period", default: 48, null: false end add_index "namespaces", ["created_at"], name: "index_namespaces_on_created_at", using: :btree @@ -702,6 +704,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do add_index "namespaces", ["parent_id", "id"], name: "index_namespaces_on_parent_id_and_id", unique: true, using: :btree add_index "namespaces", ["path"], name: "index_namespaces_on_path", using: :btree add_index "namespaces", ["path"], name: "index_namespaces_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} + add_index "namespaces", ["require_two_factor_authentication"], name: "index_namespaces_on_require_two_factor_authentication", using: :btree add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree create_table "notes", force: :cascade do |t| @@ -1246,6 +1249,8 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.boolean "authorized_projects_populated" t.boolean "ghost" t.boolean "notified_of_own_activity" + t.boolean "require_two_factor_authentication", default: false, null: false + t.integer "two_factor_grace_period", default: 48, null: false end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.3 From 1735ed613910b38c4c069da9c4637bbc4856db36 Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Tue, 14 Mar 2017 14:34:21 +0100 Subject: rename cache db column with `_cached` suffix --- db/migrate/20170124193205_add_two_factor_columns_to_users.rb | 4 ++-- db/schema.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb index bef1b2062c8..1d1021fcbb3 100644 --- a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb +++ b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb @@ -6,12 +6,12 @@ class AddTwoFactorColumnsToUsers < ActiveRecord::Migration disable_ddl_transaction! def up - add_column_with_default(:users, :require_two_factor_authentication, :boolean, default: false) + add_column_with_default(:users, :require_two_factor_authentication_from_group, :boolean, default: false) add_column_with_default(:users, :two_factor_grace_period, :integer, default: 48) end def down - remove_column(:users, :require_two_factor_authentication) + remove_column(:users, :require_two_factor_authentication_from_group) remove_column(:users, :two_factor_grace_period) end end diff --git a/db/schema.rb b/db/schema.rb index 2d2507828d4..62b9a766ff3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1249,7 +1249,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.boolean "authorized_projects_populated" t.boolean "ghost" t.boolean "notified_of_own_activity" - t.boolean "require_two_factor_authentication", default: false, null: false + t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false end -- cgit v1.2.3 From f16377e7dc762462817dd0b34e36811c55988b10 Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Wed, 5 Apr 2017 18:59:46 +0100 Subject: Protected Tags backend review changes Added changelog --- db/migrate/20170309173138_create_protected_tags.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb index 538f28479c7..796f3c90344 100644 --- a/db/migrate/20170309173138_create_protected_tags.rb +++ b/db/migrate/20170309173138_create_protected_tags.rb @@ -1,7 +1,6 @@ class CreateProtectedTags < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - # Set this constant to true if this migration requires downtime. DOWNTIME = false GITLAB_ACCESS_MASTER = 40 -- cgit v1.2.3 From 8af788e08587905bfa3455a06832ade4b3ef15c1 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Thu, 30 Mar 2017 15:38:05 +0100 Subject: Disable invalid service templates (again) --- ...0170330141723_disable_invalid_service_templates2.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/migrate/20170330141723_disable_invalid_service_templates2.rb (limited to 'db') diff --git a/db/migrate/20170330141723_disable_invalid_service_templates2.rb b/db/migrate/20170330141723_disable_invalid_service_templates2.rb new file mode 100644 index 00000000000..8424e56d8a1 --- /dev/null +++ b/db/migrate/20170330141723_disable_invalid_service_templates2.rb @@ -0,0 +1,18 @@ +# This is the same as DisableInvalidServiceTemplates. Later migrations may have +# inadventently enabled some invalid templates again. +# +class DisableInvalidServiceTemplates2 < ActiveRecord::Migration + DOWNTIME = false + + unless defined?(Service) + class Service < ActiveRecord::Base + self.inheritance_column = nil + end + end + + def up + Service.where(template: true, active: true).each do |template| + template.update(active: false) unless template.valid? + end + end +end -- cgit v1.2.3 From 7f2a2008389e09a0abf163e0ff67d672ef74df27 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Thu, 6 Apr 2017 12:47:40 +0100 Subject: Fix RuboCop for removing index --- db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'db') diff --git a/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb index 8316ee9eb9f..0237c3189a5 100644 --- a/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb +++ b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb @@ -1,6 +1,7 @@ # See http://doc.gitlab.com/ce/development/migration_style_guide.html # for more information on how to write migrations for GitLab. +# rubocop:disable RemoveIndex class RemoveIndexForUsersCurrentSignInAt < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers -- cgit v1.2.3 From 057c0d7a5c062f3030bcc46614ef2442009002de Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 6 Apr 2017 21:32:56 +0800 Subject: Also track auto-cancelling in jobs, detail: Not only tracking auto-cancelling in pipelines, we'll also track this in jobs because pipelines could be retried and the information would get lost when this happened. Also erase auto-cancelling relation for pipelines when they're retried. --- ...6114958_add_auto_canceled_by_id_to_ci_builds.rb | 9 +++++++++ ...auto_canceled_by_id_foreign_key_to_ci_builds.rb | 22 ++++++++++++++++++++++ db/schema.rb | 2 ++ 3 files changed, 33 insertions(+) create mode 100644 db/migrate/20170406114958_add_auto_canceled_by_id_to_ci_builds.rb create mode 100644 db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb (limited to 'db') diff --git a/db/migrate/20170406114958_add_auto_canceled_by_id_to_ci_builds.rb b/db/migrate/20170406114958_add_auto_canceled_by_id_to_ci_builds.rb new file mode 100644 index 00000000000..c1d803b4308 --- /dev/null +++ b/db/migrate/20170406114958_add_auto_canceled_by_id_to_ci_builds.rb @@ -0,0 +1,9 @@ +class AddAutoCanceledByIdToCiBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_builds, :auto_canceled_by_id, :integer + end +end diff --git a/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb b/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb new file mode 100644 index 00000000000..3004683933b --- /dev/null +++ b/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb @@ -0,0 +1,22 @@ +class AddAutoCanceledByIdForeignKeyToCiBuilds < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + on_delete = + if Gitlab::Database.mysql? + :nullify + else + 'SET NULL' + end + + add_concurrent_foreign_key :ci_builds, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete + end + + def down + remove_foreign_key :ci_builds, column: :auto_canceled_by_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 59dbe9fd69a..afc67dba702 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -223,6 +223,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do t.string "token" t.integer "lock_version" t.string "coverage_regex" + t.integer "auto_canceled_by_id" end add_index "ci_builds", ["commit_id", "stage_idx", "created_at"], name: "index_ci_builds_on_commit_id_and_stage_idx_and_created_at", using: :btree @@ -1300,6 +1301,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade + add_foreign_key "ci_builds", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_a2141b1522", on_delete: :nullify add_foreign_key "ci_pipelines", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_262d4c2d19", on_delete: :nullify add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade -- cgit v1.2.3 From 1ac44911b355ac18d279b7fff4c7db821689d9c7 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 6 Apr 2017 22:09:53 +0800 Subject: Bump schema version --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index afc67dba702..3797d2914d2 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: 20170405080720) do +ActiveRecord::Schema.define(version: 20170406115029) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 5f715f1d32c6f5ce25b3721bde8f476173afadc8 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 23 Mar 2017 03:54:49 +0900 Subject: Add scheduled_trigger model. Add cron parser. Plus, specs. --- .../20170322070910_create_ci_scheduled_triggers.rb | 45 ++++++++++++++++++++++ db/schema.rb | 24 ++++++++++-- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20170322070910_create_ci_scheduled_triggers.rb (limited to 'db') diff --git a/db/migrate/20170322070910_create_ci_scheduled_triggers.rb b/db/migrate/20170322070910_create_ci_scheduled_triggers.rb new file mode 100644 index 00000000000..91e4b42d2af --- /dev/null +++ b/db/migrate/20170322070910_create_ci_scheduled_triggers.rb @@ -0,0 +1,45 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateCiScheduledTriggers < 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 + create_table :ci_scheduled_triggers do |t| + t.integer "project_id" + t.datetime "deleted_at" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "owner_id" + t.string "description" + t.string "cron" + t.string "cron_time_zone" + t.datetime "next_run_at" + t.datetime "last_run_at" + t.string "ref" + end + + add_index :ci_scheduled_triggers, ["next_run_at"], name: "index_ci_scheduled_triggers_on_next_run_at", using: :btree + add_index :ci_scheduled_triggers, ["project_id"], name: "index_ci_scheduled_triggers_on_project_id", using: :btree + add_foreign_key :ci_scheduled_triggers, :users, column: :owner_id, on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index 582f68cbee7..a101ce280fe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,7 +61,6 @@ ActiveRecord::Schema.define(version: 20170405080720) 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: 20170405080720) 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" @@ -290,6 +290,23 @@ ActiveRecord::Schema.define(version: 20170405080720) 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_scheduled_triggers", force: :cascade do |t| + t.integer "project_id" + t.datetime "deleted_at" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "owner_id" + t.string "description" + t.string "cron" + t.string "cron_time_zone" + t.datetime "next_run_at" + t.datetime "last_run_at" + t.string "ref" + end + + add_index "ci_scheduled_triggers", ["next_run_at"], name: "index_ci_scheduled_triggers_on_next_run_at", using: :btree + add_index "ci_scheduled_triggers", ["project_id"], name: "index_ci_scheduled_triggers_on_project_id", using: :btree + create_table "ci_trigger_requests", force: :cascade do |t| t.integer "trigger_id", null: false t.text "variables" @@ -689,8 +706,8 @@ ActiveRecord::Schema.define(version: 20170405080720) 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 @@ -1242,8 +1259,8 @@ ActiveRecord::Schema.define(version: 20170405080720) 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" t.boolean "notified_of_own_activity" @@ -1298,6 +1315,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade + add_foreign_key "ci_scheduled_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 -- cgit v1.2.3 From 8f798e81843c155db3b6661a8d30505b3fe1d098 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 29 Mar 2017 18:50:08 +0900 Subject: Rollback --- db/schema.rb | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index a101ce280fe..7f51f4f2fdb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -290,23 +290,6 @@ ActiveRecord::Schema.define(version: 20170405080720) 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_scheduled_triggers", force: :cascade do |t| - t.integer "project_id" - t.datetime "deleted_at" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "owner_id" - t.string "description" - t.string "cron" - t.string "cron_time_zone" - t.datetime "next_run_at" - t.datetime "last_run_at" - t.string "ref" - end - - add_index "ci_scheduled_triggers", ["next_run_at"], name: "index_ci_scheduled_triggers_on_next_run_at", using: :btree - add_index "ci_scheduled_triggers", ["project_id"], name: "index_ci_scheduled_triggers_on_project_id", using: :btree - create_table "ci_trigger_requests", force: :cascade do |t| t.integer "trigger_id", null: false t.text "variables" @@ -1315,7 +1298,6 @@ ActiveRecord::Schema.define(version: 20170405080720) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade - add_foreign_key "ci_scheduled_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 -- cgit v1.2.3 From b4da589ee902654225fe915c22e0859522511e66 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 29 Mar 2017 18:50:54 +0900 Subject: Remove old migration file --- .../20170322070910_create_ci_scheduled_triggers.rb | 45 ---------------------- 1 file changed, 45 deletions(-) delete mode 100644 db/migrate/20170322070910_create_ci_scheduled_triggers.rb (limited to 'db') diff --git a/db/migrate/20170322070910_create_ci_scheduled_triggers.rb b/db/migrate/20170322070910_create_ci_scheduled_triggers.rb deleted file mode 100644 index 91e4b42d2af..00000000000 --- a/db/migrate/20170322070910_create_ci_scheduled_triggers.rb +++ /dev/null @@ -1,45 +0,0 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - -class CreateCiScheduledTriggers < 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 - create_table :ci_scheduled_triggers do |t| - t.integer "project_id" - t.datetime "deleted_at" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "owner_id" - t.string "description" - t.string "cron" - t.string "cron_time_zone" - t.datetime "next_run_at" - t.datetime "last_run_at" - t.string "ref" - end - - add_index :ci_scheduled_triggers, ["next_run_at"], name: "index_ci_scheduled_triggers_on_next_run_at", using: :btree - add_index :ci_scheduled_triggers, ["project_id"], name: "index_ci_scheduled_triggers_on_project_id", using: :btree - add_foreign_key :ci_scheduled_triggers, :users, column: :owner_id, on_delete: :cascade - end -end -- cgit v1.2.3 From 4c2435f58e8b46c25af64b85345eb49dc5341f5a Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 29 Mar 2017 18:54:59 +0900 Subject: Add ref to ci_triggers --- db/migrate/20170329095325_add_ref_to_triggers.rb | 29 ++++++++++++++++++++++++ db/schema.rb | 1 + 2 files changed, 30 insertions(+) create mode 100644 db/migrate/20170329095325_add_ref_to_triggers.rb (limited to 'db') diff --git a/db/migrate/20170329095325_add_ref_to_triggers.rb b/db/migrate/20170329095325_add_ref_to_triggers.rb new file mode 100644 index 00000000000..f8236b5a711 --- /dev/null +++ b/db/migrate/20170329095325_add_ref_to_triggers.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 AddRefToTriggers < 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 :ci_triggers, :ref, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 7f51f4f2fdb..f20f9bdfb17 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -308,6 +308,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do t.integer "project_id" t.integer "owner_id" t.string "description" + t.string "ref" end add_index "ci_triggers", ["project_id"], name: "index_ci_triggers_on_project_id", using: :btree -- cgit v1.2.3 From e32c1a5c92a80c350bbf3b70552be5cf29501fe7 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 29 Mar 2017 19:07:25 +0900 Subject: Add ci_trigger_schedules table --- .../20170329095907_create_ci_trigger_schedules.rb | 42 ++++++++++++++++++++++ db/schema.rb | 15 ++++++++ 2 files changed, 57 insertions(+) create mode 100644 db/migrate/20170329095907_create_ci_trigger_schedules.rb (limited to 'db') diff --git a/db/migrate/20170329095907_create_ci_trigger_schedules.rb b/db/migrate/20170329095907_create_ci_trigger_schedules.rb new file mode 100644 index 00000000000..42f9497cac7 --- /dev/null +++ b/db/migrate/20170329095907_create_ci_trigger_schedules.rb @@ -0,0 +1,42 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CreateCiTriggerSchedules < 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 + create_table :ci_trigger_schedules do |t| + t.integer "project_id" + t.integer "trigger_id", null: false + t.datetime "deleted_at" + t.datetime "created_at" + t.datetime "updated_at" + t.string "cron" + t.string "cron_time_zone" + t.datetime "next_run_at" + end + + add_index :ci_trigger_schedules, ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at", using: :btree + add_index :ci_trigger_schedules, ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree + add_foreign_key :ci_trigger_schedules, :ci_triggers, column: :trigger_id, on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index f20f9bdfb17..8f3b3110548 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -300,6 +300,20 @@ ActiveRecord::Schema.define(version: 20170405080720) do add_index "ci_trigger_requests", ["commit_id"], name: "index_ci_trigger_requests_on_commit_id", using: :btree + create_table "ci_trigger_schedules", force: :cascade do |t| + t.integer "project_id" + t.integer "trigger_id", null: false + t.datetime "deleted_at" + t.datetime "created_at" + t.datetime "updated_at" + t.string "cron" + t.string "cron_time_zone" + t.datetime "next_run_at" + end + + add_index "ci_trigger_schedules", ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at", using: :btree + add_index "ci_trigger_schedules", ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree + create_table "ci_triggers", force: :cascade do |t| t.string "token" t.datetime "deleted_at" @@ -1299,6 +1313,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade + add_foreign_key "ci_trigger_schedules", "ci_triggers", column: "trigger_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 -- cgit v1.2.3 From d9574c0cce97d859ca605d70374633283c93f3fa Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 1 Apr 2017 02:31:58 +0900 Subject: Maintain MR --- db/migrate/20170329095325_add_ref_to_triggers.rb | 16 ---------------- db/migrate/20170329095907_create_ci_trigger_schedules.rb | 16 ---------------- 2 files changed, 32 deletions(-) (limited to 'db') diff --git a/db/migrate/20170329095325_add_ref_to_triggers.rb b/db/migrate/20170329095325_add_ref_to_triggers.rb index f8236b5a711..6900ded4277 100644 --- a/db/migrate/20170329095325_add_ref_to_triggers.rb +++ b/db/migrate/20170329095325_add_ref_to_triggers.rb @@ -7,22 +7,6 @@ class AddRefToTriggers < ActiveRecord::Migration # 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 :ci_triggers, :ref, :string end diff --git a/db/migrate/20170329095907_create_ci_trigger_schedules.rb b/db/migrate/20170329095907_create_ci_trigger_schedules.rb index 42f9497cac7..7b2e2e2098b 100644 --- a/db/migrate/20170329095907_create_ci_trigger_schedules.rb +++ b/db/migrate/20170329095907_create_ci_trigger_schedules.rb @@ -7,22 +7,6 @@ class CreateCiTriggerSchedules < ActiveRecord::Migration # 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 create_table :ci_trigger_schedules do |t| t.integer "project_id" -- cgit v1.2.3 From 934e949726adf4428a03970d78e23555cc1d7a72 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Sat, 1 Apr 2017 17:57:52 +0900 Subject: Fix rubocop issues. Use add_concurrent_foreign_key. --- db/migrate/20170329095325_add_ref_to_triggers.rb | 4 ---- db/migrate/20170329095907_create_ci_trigger_schedules.rb | 15 +++++++++------ db/schema.rb | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'db') diff --git a/db/migrate/20170329095325_add_ref_to_triggers.rb b/db/migrate/20170329095325_add_ref_to_triggers.rb index 6900ded4277..4aa52dd8f8f 100644 --- a/db/migrate/20170329095325_add_ref_to_triggers.rb +++ b/db/migrate/20170329095325_add_ref_to_triggers.rb @@ -1,10 +1,6 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddRefToTriggers < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - # Set this constant to true if this migration requires downtime. DOWNTIME = false def change diff --git a/db/migrate/20170329095907_create_ci_trigger_schedules.rb b/db/migrate/20170329095907_create_ci_trigger_schedules.rb index 7b2e2e2098b..3dcd05175c0 100644 --- a/db/migrate/20170329095907_create_ci_trigger_schedules.rb +++ b/db/migrate/20170329095907_create_ci_trigger_schedules.rb @@ -1,13 +1,11 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class CreateCiTriggerSchedules < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - # Set this constant to true if this migration requires downtime. DOWNTIME = false - def change + disable_ddl_transaction! + + def up create_table :ci_trigger_schedules do |t| t.integer "project_id" t.integer "trigger_id", null: false @@ -21,6 +19,11 @@ class CreateCiTriggerSchedules < ActiveRecord::Migration add_index :ci_trigger_schedules, ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at", using: :btree add_index :ci_trigger_schedules, ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree - add_foreign_key :ci_trigger_schedules, :ci_triggers, column: :trigger_id, on_delete: :cascade + add_concurrent_foreign_key :ci_trigger_schedules, :ci_triggers, column: :trigger_id, on_delete: :cascade + end + + def down + remove_foreign_key :ci_trigger_schedules, column: :trigger_id + drop_table :ci_trigger_schedules end end diff --git a/db/schema.rb b/db/schema.rb index 8f3b3110548..7d9f969c2e1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1313,7 +1313,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do add_foreign_key "boards", "projects" add_foreign_key "chat_teams", "namespaces", on_delete: :cascade - add_foreign_key "ci_trigger_schedules", "ci_triggers", column: "trigger_id", on_delete: :cascade + add_foreign_key "ci_trigger_schedules", "ci_triggers", column: "trigger_id", name: "fk_90a406cc94", on_delete: :cascade add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade add_foreign_key "issue_metrics", "issues", on_delete: :cascade add_foreign_key "label_priorities", "labels", on_delete: :cascade -- cgit v1.2.3 From 4688eb47c6fe135fb9baad5a5d56b1dfa685cc7f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 5 Apr 2017 01:54:45 +0900 Subject: Rename cron_time_zone to cron_timezone. Separate add_concurrent_foreign_key. --- db/migrate/20170329095907_create_ci_trigger_schedules.rb | 16 ++++------------ db/migrate/20170404163427_add_trigger_id_foreign_key.rb | 15 +++++++++++++++ db/schema.rb | 2 +- 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20170404163427_add_trigger_id_foreign_key.rb (limited to 'db') diff --git a/db/migrate/20170329095907_create_ci_trigger_schedules.rb b/db/migrate/20170329095907_create_ci_trigger_schedules.rb index 3dcd05175c0..cfcfa27ebb5 100644 --- a/db/migrate/20170329095907_create_ci_trigger_schedules.rb +++ b/db/migrate/20170329095907_create_ci_trigger_schedules.rb @@ -3,9 +3,7 @@ class CreateCiTriggerSchedules < ActiveRecord::Migration DOWNTIME = false - disable_ddl_transaction! - - def up + def change create_table :ci_trigger_schedules do |t| t.integer "project_id" t.integer "trigger_id", null: false @@ -13,17 +11,11 @@ class CreateCiTriggerSchedules < ActiveRecord::Migration t.datetime "created_at" t.datetime "updated_at" t.string "cron" - t.string "cron_time_zone" + t.string "cron_timezone" t.datetime "next_run_at" end - add_index :ci_trigger_schedules, ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at", using: :btree - add_index :ci_trigger_schedules, ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree - add_concurrent_foreign_key :ci_trigger_schedules, :ci_triggers, column: :trigger_id, on_delete: :cascade - end - - def down - remove_foreign_key :ci_trigger_schedules, column: :trigger_id - drop_table :ci_trigger_schedules + add_index :ci_trigger_schedules, :next_run_at + add_index :ci_trigger_schedules, :project_id end end diff --git a/db/migrate/20170404163427_add_trigger_id_foreign_key.rb b/db/migrate/20170404163427_add_trigger_id_foreign_key.rb new file mode 100644 index 00000000000..6679a95ca11 --- /dev/null +++ b/db/migrate/20170404163427_add_trigger_id_foreign_key.rb @@ -0,0 +1,15 @@ +class AddTriggerIdForeignKey < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key :ci_trigger_schedules, :ci_triggers, column: :trigger_id, on_delete: :cascade + end + + def down + remove_foreign_key :ci_trigger_schedules, column: :trigger_id + end +end diff --git a/db/schema.rb b/db/schema.rb index 7d9f969c2e1..a564a4b6a12 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -307,7 +307,7 @@ ActiveRecord::Schema.define(version: 20170405080720) do t.datetime "created_at" t.datetime "updated_at" t.string "cron" - t.string "cron_time_zone" + t.string "cron_timezone" t.datetime "next_run_at" end -- cgit v1.2.3 From 7b09a484f1ecc422ce14602d9ee15e5a59100264 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 5 Apr 2017 02:31:15 +0900 Subject: Fix unnecessary changes in schema.rb --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index a564a4b6a12..58425d637c1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -61,6 +61,7 @@ ActiveRecord::Schema.define(version: 20170405080720) 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 +111,6 @@ ActiveRecord::Schema.define(version: 20170405080720) 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" @@ -704,8 +704,8 @@ ActiveRecord::Schema.define(version: 20170405080720) 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 @@ -1257,8 +1257,8 @@ ActiveRecord::Schema.define(version: 20170405080720) 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 "ghost" t.boolean "notified_of_own_activity" -- cgit v1.2.3 From 163e9f99ab29524bca204fbd0d0aabc1a1813e4a Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 6 Apr 2017 12:25:09 +0200 Subject: Fix indexes in container repositories table --- db/migrate/20170322013926_create_container_repository.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170322013926_create_container_repository.rb b/db/migrate/20170322013926_create_container_repository.rb index 32eba3903b1..91540bc88bd 100644 --- a/db/migrate/20170322013926_create_container_repository.rb +++ b/db/migrate/20170322013926_create_container_repository.rb @@ -5,13 +5,12 @@ class CreateContainerRepository < ActiveRecord::Migration def change create_table :container_repositories do |t| - t.references :project, foreign_key: true, null: false + t.references :project, foreign_key: true, index: true, null: false t.string :name, null: false t.timestamps null: false end - add_index :container_repositories, :project_id add_index :container_repositories, [:project_id, :name], unique: true end end -- cgit v1.2.3 From 503f8822758fd6deb93e448bf37e1e3e70422e29 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 6 Apr 2017 23:47:37 +0800 Subject: Fix rubocop offenses --- db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb index 8316ee9eb9f..6013598b835 100644 --- a/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb +++ b/db/migrate/20170402231018_remove_index_for_users_current_sign_in_at.rb @@ -14,7 +14,7 @@ class RemoveIndexForUsersCurrentSignInAt < ActiveRecord::Migration if Gitlab::Database.postgresql? execute 'DROP INDEX CONCURRENTLY index_users_on_current_sign_in_at;' else - remove_index :users, :current_sign_in_at + remove_concurrent_index :users, :current_sign_in_at end end end -- cgit v1.2.3 From 828d81ee1f6aaaf6ab9de1ed0c675ff961831c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 6 Apr 2017 16:20:27 +0000 Subject: Optimise trace handling code to use streaming instead of full read --- db/fixtures/development/14_pipelines.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb index 534847a7107..3c42f7db6d5 100644 --- a/db/fixtures/development/14_pipelines.rb +++ b/db/fixtures/development/14_pipelines.rb @@ -130,7 +130,7 @@ class Gitlab::Seeder::Pipelines def setup_build_log(build) if %w(running success failed).include?(build.status) - build.trace = FFaker::Lorem.paragraphs(6).join("\n\n") + build.trace.set(FFaker::Lorem.paragraphs(6).join("\n\n")) end end -- cgit v1.2.3 From 29cd3b0b3f0f7956986a63421bb13e6bf654ee83 Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Thu, 6 Apr 2017 13:02:57 -0500 Subject: Fixed rubocop failure for the add_two_factor_columns_migration --- db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb b/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb index ca4429c676c..df5cddeb205 100644 --- a/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb +++ b/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb @@ -16,6 +16,6 @@ class AddTwoFactorColumnsToNamespaces < ActiveRecord::Migration remove_column(:namespaces, :require_two_factor_authentication) remove_column(:namespaces, :two_factor_grace_period) - remove_index(:namespaces, :require_two_factor_authentication) if index_exists?(:namespaces, :require_two_factor_authentication) + remove_concurrent_index(:namespaces, :require_two_factor_authentication) if index_exists?(:namespaces, :require_two_factor_authentication) end end -- cgit v1.2.3 From 126c651280218a008f493558ec8ec51aee412fd6 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 6 Apr 2017 15:16:50 -0500 Subject: Update schema.rb version --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index c9dca702465..f1783ab1b05 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: 20170404170532) do +ActiveRecord::Schema.define(version: 20170405080720) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "pg_trgm" -- cgit v1.2.3 From 03088552549ed1631bb16c1bf3d0bef3613ec793 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 7 Apr 2017 14:47:29 +0200 Subject: Fix ref reference --- ...0170407114956_add_ref_to_ci_trigger_schedule.rb | 31 ++++++++++++++++++++++ ...0407122426_add_active_to_ci_trigger_schedule.rb | 31 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb create mode 100644 db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb (limited to 'db') diff --git a/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb b/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb new file mode 100644 index 00000000000..9bf82e49aec --- /dev/null +++ b/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.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 AddRefToCiTriggerSchedule < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index", "remove_concurrent_index" or + # "add_column_with_default" you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + + def change + add_column :ci_trigger_schedules, :ref, :string + end +end diff --git a/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb b/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb new file mode 100644 index 00000000000..1da31c66fa6 --- /dev/null +++ b/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.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 AddActiveToCiTriggerSchedule < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index", "remove_concurrent_index" or + # "add_column_with_default" you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + + def change + add_column :ci_trigger_schedules, :active, :boolean + end +end -- cgit v1.2.3 From 21a7aed9a7330382300bc93b8927609e65ee6390 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 7 Apr 2017 16:02:13 +0200 Subject: Update tests to cover trigger schedule --- db/schema.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 16f3f293079..b74aebc8305 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: 20170406115029) do +ActiveRecord::Schema.define(version: 20170407122426) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -311,6 +311,8 @@ ActiveRecord::Schema.define(version: 20170406115029) do t.string "cron" t.string "cron_timezone" t.datetime "next_run_at" + t.string "ref" + t.boolean "active" end add_index "ci_trigger_schedules", ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at", using: :btree -- cgit v1.2.3 From 7cee650d0c75c0b9c229965711437779b847130f Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 7 Apr 2017 16:06:51 +0200 Subject: Update migrations --- ...0170407114956_add_ref_to_ci_trigger_schedule.rb | 22 ---------------------- ...0407122426_add_active_to_ci_trigger_schedule.rb | 22 ---------------------- ...07140450_add_index_to_next_run_at_and_active.rb | 12 ++++++++++++ db/schema.rb | 3 ++- 4 files changed, 14 insertions(+), 45 deletions(-) create mode 100644 db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb (limited to 'db') diff --git a/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb b/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb index 9bf82e49aec..523a306f127 100644 --- a/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb +++ b/db/migrate/20170407114956_add_ref_to_ci_trigger_schedule.rb @@ -1,30 +1,8 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddRefToCiTriggerSchedule < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - # Set this constant to true if this migration requires downtime. DOWNTIME = false - # When a migration requires downtime you **must** uncomment the following - # constant and define a short and easy to understand explanation as to why the - # migration requires downtime. - # DOWNTIME_REASON = '' - - # When using the methods "add_concurrent_index", "remove_concurrent_index" or - # "add_column_with_default" you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - def change add_column :ci_trigger_schedules, :ref, :string end diff --git a/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb b/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb index 1da31c66fa6..36892118ac0 100644 --- a/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb +++ b/db/migrate/20170407122426_add_active_to_ci_trigger_schedule.rb @@ -1,30 +1,8 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class AddActiveToCiTriggerSchedule < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - # Set this constant to true if this migration requires downtime. DOWNTIME = false - # When a migration requires downtime you **must** uncomment the following - # constant and define a short and easy to understand explanation as to why the - # migration requires downtime. - # DOWNTIME_REASON = '' - - # When using the methods "add_concurrent_index", "remove_concurrent_index" or - # "add_column_with_default" you must disable the use of transactions - # as these methods can not run in an existing transaction. - # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure - # that either of them is the _only_ method called in the migration, - # any other changes should go in a separate migration. - # This ensures that upon failure _only_ the index creation or removing fails - # and can be retried or reverted easily. - # - # To disable transactions uncomment the following line and remove these - # comments: - # disable_ddl_transaction! - def change add_column :ci_trigger_schedules, :active, :boolean end diff --git a/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb b/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb new file mode 100644 index 00000000000..887632da20e --- /dev/null +++ b/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb @@ -0,0 +1,12 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexToNextRunAtAndActive < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_index :ci_trigger_schedules, [:active, :next_run_at] + end +end diff --git a/db/schema.rb b/db/schema.rb index b74aebc8305..2854416a8ef 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: 20170407122426) do +ActiveRecord::Schema.define(version: 20170407140450) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -315,6 +315,7 @@ ActiveRecord::Schema.define(version: 20170407122426) do t.boolean "active" end + add_index "ci_trigger_schedules", ["active", "next_run_at"], name: "index_ci_trigger_schedules_on_active_and_next_run_at", using: :btree add_index "ci_trigger_schedules", ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at", using: :btree add_index "ci_trigger_schedules", ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree -- cgit v1.2.3 From bea1aba9caff0b19bc08004cfb80cb9e5f1b6b89 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 7 Apr 2017 10:31:49 -0500 Subject: Update schema.rb --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/schema.rb b/db/schema.rb index 457957536b0..a8ca4d4757d 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: 20170405080720) do +ActiveRecord::Schema.define(version: 20170406115029) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "pg_trgm" -- cgit v1.2.3 From 0872b854cb4861351893ad78c4d4a86c61a2eccf Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 7 Apr 2017 17:34:41 +0200 Subject: Another round of code review --- .../20170407140450_add_index_to_next_run_at_and_active.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'db') diff --git a/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb b/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb index 887632da20e..e1382318d3c 100644 --- a/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb +++ b/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb @@ -6,7 +6,13 @@ class AddIndexToNextRunAtAndActive < ActiveRecord::Migration DOWNTIME = false - def change - add_index :ci_trigger_schedules, [:active, :next_run_at] + disable_ddl_transaction! + + def up + add_concurrent_index :ci_trigger_schedules, [:active, :next_run_at] + end + + def down + remove_index :ci_trigger_schedules, [:active, :next_run_at] end end -- cgit v1.2.3 From 3ea4a13925d7989288101ba40b25b02fa49ae23c Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 7 Apr 2017 18:05:39 +0200 Subject: Yet, another errors --- db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db') diff --git a/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb b/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb index e1382318d3c..626c2a67fdc 100644 --- a/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb +++ b/db/migrate/20170407140450_add_index_to_next_run_at_and_active.rb @@ -13,6 +13,6 @@ class AddIndexToNextRunAtAndActive < ActiveRecord::Migration end def down - remove_index :ci_trigger_schedules, [:active, :next_run_at] + remove_concurrent_index :ci_trigger_schedules, [:active, :next_run_at] end end -- cgit v1.2.3 From ad27f20426975cf515fd55e4b5b75e5d4703315c Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Mon, 10 Apr 2017 08:48:44 +1100 Subject: Periodically clean up temporary upload files to recover storage space --- .../20170408033905_remove_old_cache_directories.rb | 23 ++++++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/post_migrate/20170408033905_remove_old_cache_directories.rb (limited to 'db') diff --git a/db/post_migrate/20170408033905_remove_old_cache_directories.rb b/db/post_migrate/20170408033905_remove_old_cache_directories.rb new file mode 100644 index 00000000000..b23b52896b9 --- /dev/null +++ b/db/post_migrate/20170408033905_remove_old_cache_directories.rb @@ -0,0 +1,23 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +# Remove all files from old custom carrierwave's cache directories. +# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9466 + +class RemoveOldCacheDirectories < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + # FileUploader cache. + FileUtils.rm_rf(Dir[Rails.root.join('public', 'uploads', 'tmp', '*')]) + end + + def down + # Old cache is not supposed to be recoverable. + # So the down method is empty. + end +end diff --git a/db/schema.rb b/db/schema.rb index d400c823387..3422847d729 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: 20170407140450) do +ActiveRecord::Schema.define(version: 20170408033905) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "pg_trgm" -- cgit v1.2.3 From e585b77730b2a38173453bb5e437628fe6eb9844 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 6 Apr 2017 17:52:15 +0300 Subject: Change project view default for existing users and anonymous visitors to files+readme Signed-off-by: Dmitriy Zaporozhets --- .../20170406142253_migrate_user_project_view.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 db/post_migrate/20170406142253_migrate_user_project_view.rb (limited to 'db') diff --git a/db/post_migrate/20170406142253_migrate_user_project_view.rb b/db/post_migrate/20170406142253_migrate_user_project_view.rb new file mode 100644 index 00000000000..22f0f2ac200 --- /dev/null +++ b/db/post_migrate/20170406142253_migrate_user_project_view.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 MigrateUserProjectView < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + update_column_in_batches(:users, :project_view, 2) do |table, query| + query.where(table[:project_view].eq(0)) + end + end + + def down + # Nothing can be done to restore old values + end +end -- cgit v1.2.3 From d33fc982f554a0c58d19b81f31967134b2140c72 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 10 Apr 2017 16:18:58 -0400 Subject: Move the nested groups seed behind an environment flag This seed downloads 2.1 GB worth of repositories. Google can afford the bandwidth, but if a person using the GDK is on a metered connection, that's not so great. Also the GDK test suite runs this seed, so every CI run for that project had to download those as well. Needlessly wasteful. --- db/fixtures/development/17_cycle_analytics.rb | 6 ++- db/fixtures/development/20_nested_groups.rb | 68 +++++++++++++++------------ 2 files changed, 41 insertions(+), 33 deletions(-) (limited to 'db') diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 4bc735916c1..0d7eb1a7c93 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -223,7 +223,9 @@ class Gitlab::Seeder::CycleAnalytics end Gitlab::Seeder.quiet do - if ENV['SEED_CYCLE_ANALYTICS'] + flag = 'SEED_CYCLE_ANALYTICS' + + if ENV[flag] Project.all.each do |project| seeder = Gitlab::Seeder::CycleAnalytics.new(project) seeder.seed! @@ -235,6 +237,6 @@ Gitlab::Seeder.quiet do seeder = Gitlab::Seeder::CycleAnalytics.new(Project.order(:id).first, perf: true) seeder.seed_metrics! else - puts "Not running the cycle analytics seed file. Use the `SEED_CYCLE_ANALYTICS` environment variable to enable it." + puts "Skipped. Use the `#{flag}` environment variable to enable." end end diff --git a/db/fixtures/development/20_nested_groups.rb b/db/fixtures/development/20_nested_groups.rb index d8dddc3fee9..2bc78e120a5 100644 --- a/db/fixtures/development/20_nested_groups.rb +++ b/db/fixtures/development/20_nested_groups.rb @@ -27,43 +27,49 @@ 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' - ] + flag = 'SEED_NESTED_GROUPS' - user = User.admins.first + if ENV[flag] + 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' + ] - 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) + user = User.admins.first - 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_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) - project = Projects::CreateService.new(user, params).execute - project.send(:_run_after_commit_queue) + params = { + import_url: url, + namespace_id: group.id, + path: project_path, + name: project_path, + description: FFaker::Lorem.sentence, + visibility_level: Gitlab::VisibilityLevel.values.sample + } - if project.valid? - print '.' - else - print 'F' + project = Projects::CreateService.new(user, params).execute + project.send(:_run_after_commit_queue) + + if project.valid? + print '.' + else + print 'F' + end end + else + puts "Skipped. Use the `#{flag}` environment variable to enable." end end end -- cgit v1.2.3 From 962bf01e69add14bceb3a901a143fcfba486abf3 Mon Sep 17 00:00:00 2001 From: "Z.J. van de Weg" Date: Fri, 7 Apr 2017 15:56:08 +0200 Subject: Add foreign key on trigger requests I started out as I missed the foreign key on ci_triggers and projects. However, it seemed Yorick caught this already on gitlab-org/gitlab-ce!9388. Still I found a missing foreign key, between the trigger requests and triggers. This commit adds it, and removes the depend: :destroy on the Rails model Ci::Triggers --- ...0407135259_add_foreigh_key_trigger_requests_trigger.rb | 15 +++++++++++++++ db/schema.rb | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb (limited to 'db') diff --git a/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb b/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb new file mode 100644 index 00000000000..81761c65a9f --- /dev/null +++ b/db/migrate/20170407135259_add_foreigh_key_trigger_requests_trigger.rb @@ -0,0 +1,15 @@ +class AddForeighKeyTriggerRequestsTrigger < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key(:ci_trigger_requests, :ci_triggers, column: :trigger_id) + end + + def down + remove_foreign_key(:ci_trigger_requests, column: :trigger_id) + end +end diff --git a/db/schema.rb b/db/schema.rb index 3422847d729..5689f7331dc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,6 +12,7 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20170408033905) do + # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "pg_trgm" @@ -1356,6 +1357,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do add_foreign_key "chat_teams", "namespaces", on_delete: :cascade add_foreign_key "ci_builds", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_a2141b1522", on_delete: :nullify add_foreign_key "ci_pipelines", "ci_pipelines", column: "auto_canceled_by_id", name: "fk_262d4c2d19", on_delete: :nullify + add_foreign_key "ci_trigger_requests", "ci_triggers", column: "trigger_id", name: "fk_b8ec8b7245", on_delete: :cascade add_foreign_key "ci_trigger_schedules", "ci_triggers", column: "trigger_id", name: "fk_90a406cc94", on_delete: :cascade add_foreign_key "ci_triggers", "users", column: "owner_id", name: "fk_e8e10d1964", on_delete: :cascade add_foreign_key "container_repositories", "projects" -- cgit v1.2.3 From c41df67676c46c09642a0437c5b915ca4f93a521 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Mon, 10 Apr 2017 11:23:28 +0100 Subject: removes redundant code from database.rb --- db/migrate/20130218141258_convert_closed_to_state_in_issue.rb | 2 +- db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb | 2 +- db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb | 2 +- db/migrate/20130315124931_user_color_scheme.rb | 2 +- db/migrate/20131112220935_add_visibility_level_to_projects.rb | 2 +- db/migrate/20140313092127_migrate_already_imported_projects.rb | 2 +- db/migrate/20141007100818_add_visibility_level_to_snippet.rb | 2 +- db/migrate/20151209144329_migrate_ci_web_hooks.rb | 2 +- db/migrate/20151209145909_migrate_ci_emails.rb | 2 +- db/migrate/20151210125232_migrate_ci_slack_service.rb | 2 +- db/migrate/20151210125927_migrate_ci_hip_chat_service.rb | 2 +- .../20170301205640_migrate_build_events_to_pipeline_events.rb | 1 - 12 files changed, 11 insertions(+), 12 deletions(-) (limited to 'db') diff --git a/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb index 94c0a6845d5..67a0d3b53eb 100644 --- a/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb +++ b/db/migrate/20130218141258_convert_closed_to_state_in_issue.rb @@ -1,6 +1,6 @@ # rubocop:disable all class ConvertClosedToStateInIssue < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value}" diff --git a/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb b/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb index 64a9c761352..307fc6a023d 100644 --- a/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb +++ b/db/migrate/20130218141327_convert_closed_to_state_in_merge_request.rb @@ -1,6 +1,6 @@ # rubocop:disable all class ConvertClosedToStateInMergeRequest < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up execute "UPDATE #{table_name} SET state = 'merged' WHERE closed = #{true_value} AND merged = #{true_value}" diff --git a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb index 41508c2dc95..d12703cf3b2 100644 --- a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb +++ b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb @@ -1,6 +1,6 @@ # rubocop:disable all class ConvertClosedToStateInMilestone < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value}" diff --git a/db/migrate/20130315124931_user_color_scheme.rb b/db/migrate/20130315124931_user_color_scheme.rb index 06e28a49d9d..09af928fde7 100644 --- a/db/migrate/20130315124931_user_color_scheme.rb +++ b/db/migrate/20130315124931_user_color_scheme.rb @@ -1,6 +1,6 @@ # rubocop:disable all class UserColorScheme < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up add_column :users, :color_scheme_id, :integer, null: false, default: 1 diff --git a/db/migrate/20131112220935_add_visibility_level_to_projects.rb b/db/migrate/20131112220935_add_visibility_level_to_projects.rb index 5efc17b228e..86d73753adc 100644 --- a/db/migrate/20131112220935_add_visibility_level_to_projects.rb +++ b/db/migrate/20131112220935_add_visibility_level_to_projects.rb @@ -1,6 +1,6 @@ # rubocop:disable all class AddVisibilityLevelToProjects < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def self.up add_column :projects, :visibility_level, :integer, :default => 0, :null => false diff --git a/db/migrate/20140313092127_migrate_already_imported_projects.rb b/db/migrate/20140313092127_migrate_already_imported_projects.rb index f2e91fe1b40..0afc26b8764 100644 --- a/db/migrate/20140313092127_migrate_already_imported_projects.rb +++ b/db/migrate/20140313092127_migrate_already_imported_projects.rb @@ -1,6 +1,6 @@ # rubocop:disable all class MigrateAlreadyImportedProjects < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up execute("UPDATE projects SET import_status = 'finished' WHERE imported = #{true_value}") diff --git a/db/migrate/20141007100818_add_visibility_level_to_snippet.rb b/db/migrate/20141007100818_add_visibility_level_to_snippet.rb index 688d8578478..0c14f75c154 100644 --- a/db/migrate/20141007100818_add_visibility_level_to_snippet.rb +++ b/db/migrate/20141007100818_add_visibility_level_to_snippet.rb @@ -1,6 +1,6 @@ # rubocop:disable all class AddVisibilityLevelToSnippet < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up add_column :snippets, :visibility_level, :integer, :default => 0, :null => false diff --git a/db/migrate/20151209144329_migrate_ci_web_hooks.rb b/db/migrate/20151209144329_migrate_ci_web_hooks.rb index cb1e556623a..62a6d334f04 100644 --- a/db/migrate/20151209144329_migrate_ci_web_hooks.rb +++ b/db/migrate/20151209144329_migrate_ci_web_hooks.rb @@ -1,6 +1,6 @@ # rubocop:disable all class MigrateCiWebHooks < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up execute( diff --git a/db/migrate/20151209145909_migrate_ci_emails.rb b/db/migrate/20151209145909_migrate_ci_emails.rb index 6b7a106814d..5de7b205fb1 100644 --- a/db/migrate/20151209145909_migrate_ci_emails.rb +++ b/db/migrate/20151209145909_migrate_ci_emails.rb @@ -1,6 +1,6 @@ # rubocop:disable all class MigrateCiEmails < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up # This inserts a new service: BuildsEmailService diff --git a/db/migrate/20151210125232_migrate_ci_slack_service.rb b/db/migrate/20151210125232_migrate_ci_slack_service.rb index 633d5148d97..fff130b7b10 100644 --- a/db/migrate/20151210125232_migrate_ci_slack_service.rb +++ b/db/migrate/20151210125232_migrate_ci_slack_service.rb @@ -1,6 +1,6 @@ # rubocop:disable all class MigrateCiSlackService < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up properties_query = 'SELECT properties FROM ci_services ' \ diff --git a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb b/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb index dae084ce180..824f6f84195 100644 --- a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb +++ b/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb @@ -1,6 +1,6 @@ # rubocop:disable all class MigrateCiHipChatService < ActiveRecord::Migration - include Gitlab::Database + include Gitlab::Database::MigrationHelpers def up # From properties strip `hipchat_` key 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 index 2dd14ee5a78..04bf89c9687 100644 --- a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb +++ b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb @@ -1,6 +1,5 @@ class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers - include Gitlab::Database DOWNTIME = false -- cgit v1.2.3 From ebd5e9b4549ebc80155a5a8f139efdb40b6f8b12 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 5 Apr 2017 13:19:59 +0100 Subject: Port 'Add EE usage ping' to CE CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/557 --- .../20160713222618_add_usage_ping_to_application_settings.rb | 7 +++++++ db/schema.rb | 1 + 2 files changed, 8 insertions(+) create mode 100644 db/migrate/20160713222618_add_usage_ping_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb b/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb new file mode 100644 index 00000000000..c7c5cdf7a56 --- /dev/null +++ b/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb @@ -0,0 +1,7 @@ +class AddUsagePingToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + def change + add_column :application_settings, :usage_ping_enabled, :boolean, default: true, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 5689f7331dc..7c5bb94dfb0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -116,6 +116,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do t.integer "unique_ips_limit_time_window" t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false + t.boolean "usage_ping_enabled", default: true, null: false end create_table "audit_events", force: :cascade do |t| -- cgit v1.2.3 From c53afeda0c2ee0cda89c235c9e8799baa1cfdc1a Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 5 Apr 2017 13:49:22 +0100 Subject: Port 'Add uuid to usage ping' to CE CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1521 --- .../20170328010804_add_uuid_to_application_settings.rb | 16 ++++++++++++++++ db/schema.rb | 1 + 2 files changed, 17 insertions(+) create mode 100644 db/migrate/20170328010804_add_uuid_to_application_settings.rb (limited to 'db') diff --git a/db/migrate/20170328010804_add_uuid_to_application_settings.rb b/db/migrate/20170328010804_add_uuid_to_application_settings.rb new file mode 100644 index 00000000000..5dfcc751c7b --- /dev/null +++ b/db/migrate/20170328010804_add_uuid_to_application_settings.rb @@ -0,0 +1,16 @@ +class AddUuidToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column :application_settings, :uuid, :string + execute("UPDATE application_settings SET uuid = #{quote(SecureRandom.uuid)}") + end + + def down + remove_column :application_settings, :uuid + end +end diff --git a/db/schema.rb b/db/schema.rb index 7c5bb94dfb0..1c592dd5d6d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -117,6 +117,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do t.boolean "unique_ips_limit_enabled", default: false, null: false t.decimal "polling_interval_multiplier", default: 1.0, null: false t.boolean "usage_ping_enabled", default: true, null: false + t.string "uuid" end create_table "audit_events", force: :cascade do |t| -- cgit v1.2.3 From 2951a8543ef97ceb1bcaca5f5140d822729c950b Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 5 Oct 2016 16:41:32 +0200 Subject: Add user activity service and spec. Also added relevant - NOT offline - migration It uses a user activity table instead of a column in users. Tested with mySQL and postgreSQL --- .../20161007073613_create_user_activities.rb | 27 ++++++++++++++++++++++ db/schema.rb | 8 +++++++ 2 files changed, 35 insertions(+) create mode 100644 db/migrate/20161007073613_create_user_activities.rb (limited to 'db') diff --git a/db/migrate/20161007073613_create_user_activities.rb b/db/migrate/20161007073613_create_user_activities.rb new file mode 100644 index 00000000000..4239cebd8f6 --- /dev/null +++ b/db/migrate/20161007073613_create_user_activities.rb @@ -0,0 +1,27 @@ +class CreateUserActivities < ActiveRecord::Migration + # 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 = '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 + # 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 + create_table :user_activities do |t| + t.belongs_to :user, index: { unique: true }, foreign_key: { on_delete: :cascade } + t.datetime :last_activity_at, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1c592dd5d6d..3ed28a02de2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1230,6 +1230,13 @@ ActiveRecord::Schema.define(version: 20170408033905) do 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_activities", force: :cascade do |t| + t.integer "user_id" + t.datetime "last_activity_at", null: false + end + + add_index "user_activities", ["user_id"], name: "index_user_activities_on_user_id", unique: true, using: :btree + create_table "user_agent_details", force: :cascade do |t| t.string "user_agent", null: false t.string "ip_address", null: false @@ -1389,4 +1396,5 @@ ActiveRecord::Schema.define(version: 20170408033905) 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" + add_foreign_key "user_activities", "users", on_delete: :cascade end -- cgit v1.2.3 From 3cb84e06b7a118fb46b4e1e0d4885026c9d4a4d1 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Fri, 25 Nov 2016 17:10:25 +0100 Subject: Remove user activities table and use redis instead of PG for recording activities Refactored specs and added a post deployment migration to remove the activity users table. --- .../20161128170531_drop_user_activities_table.rb | 23 ++++++++++++++++++++++ db/schema.rb | 8 -------- 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 db/post_migrate/20161128170531_drop_user_activities_table.rb (limited to 'db') diff --git a/db/post_migrate/20161128170531_drop_user_activities_table.rb b/db/post_migrate/20161128170531_drop_user_activities_table.rb new file mode 100644 index 00000000000..3ece0722821 --- /dev/null +++ b/db/post_migrate/20161128170531_drop_user_activities_table.rb @@ -0,0 +1,23 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class DropUserActivitiesTable < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + # 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 + drop_table :user_activities + end +end diff --git a/db/schema.rb b/db/schema.rb index 3ed28a02de2..1c592dd5d6d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1230,13 +1230,6 @@ ActiveRecord::Schema.define(version: 20170408033905) do 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_activities", force: :cascade do |t| - t.integer "user_id" - t.datetime "last_activity_at", null: false - end - - add_index "user_activities", ["user_id"], name: "index_user_activities_on_user_id", unique: true, using: :btree - create_table "user_agent_details", force: :cascade do |t| t.string "user_agent", null: false t.string "ip_address", null: false @@ -1396,5 +1389,4 @@ ActiveRecord::Schema.define(version: 20170408033905) 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" - add_foreign_key "user_activities", "users", on_delete: :cascade end -- cgit v1.2.3 From d4da926f48503125307fe3d4a4f3952df92fc1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 7 Mar 2017 19:35:32 +0100 Subject: Add new ScheduleUpdateUserActivityWorker and UpdateUserActivityWorker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- db/migrate/20170307125949_add_last_activity_on_to_users.rb | 9 +++++++++ db/schema.rb | 1 + 2 files changed, 10 insertions(+) create mode 100644 db/migrate/20170307125949_add_last_activity_on_to_users.rb (limited to 'db') diff --git a/db/migrate/20170307125949_add_last_activity_on_to_users.rb b/db/migrate/20170307125949_add_last_activity_on_to_users.rb new file mode 100644 index 00000000000..0100836b473 --- /dev/null +++ b/db/migrate/20170307125949_add_last_activity_on_to_users.rb @@ -0,0 +1,9 @@ +class AddLastActivityOnToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :users, :last_activity_on, :date + end +end diff --git a/db/schema.rb b/db/schema.rb index 1c592dd5d6d..9ce9df68de8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1303,6 +1303,7 @@ ActiveRecord::Schema.define(version: 20170408033905) do t.string "organization" t.boolean "authorized_projects_populated" t.boolean "ghost" + t.date "last_activity_on" t.boolean "notified_of_own_activity" t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false -- cgit v1.2.3 From 73c57fd3b0c6f4e66147f5eb0360ce99d26123b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 24 Mar 2017 18:04:57 +0100 Subject: Add a post-deploy migration to migrate from former Redis activity to DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- ...te_user_activities_to_users_last_activity_on.rb | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb (limited to 'db') diff --git a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb new file mode 100644 index 00000000000..9ad36482c8a --- /dev/null +++ b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb @@ -0,0 +1,87 @@ +class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + DOWNTIME = false + USER_ACTIVITY_SET_KEY = 'user/activities'.freeze + ACTIVITIES_PER_PAGE = 100 + TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED = Time.utc(2016, 12, 1) + + def up + return if activities_count(TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED, Time.now).zero? + + day = Time.at(activities(TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED, Time.now).first.second) + + transaction do + while day <= Time.now.utc.tomorrow + persist_last_activity_on(day: day) + day = day.tomorrow + end + end + end + + def down + # This ensures we don't lock all users for the duration of the migration. + update_column_in_batches(:users, :last_activity_on, nil) do |table, query| + query.where(table[:last_activity_on].not_eq(nil)) + end + end + + private + + def persist_last_activity_on(day:, page: 1) + activities_count = activities_count(day.at_beginning_of_day, day.at_end_of_day) + + return if activities_count.zero? + + activities = activities(day.at_beginning_of_day, day.at_end_of_day, page: page) + + update_sql = + Arel::UpdateManager.new(ActiveRecord::Base). + table(users_table). + set(users_table[:last_activity_on] => day.to_date). + where(users_table[:username].in(activities.map(&:first))). + to_sql + + connection.exec_update(update_sql, self.class.name, []) + + unless last_page?(page, activities_count) + persist_last_activity_on(day: day, page: page + 1) + end + end + + def users_table + @users_table ||= Arel::Table.new(:users) + end + + def activities(from, to, page: 1) + Gitlab::Redis.with do |redis| + redis.zrangebyscore(USER_ACTIVITY_SET_KEY, from.to_i, to.to_i, + with_scores: true, + limit: limit(page)) + end + end + + def activities_count(from, to) + Gitlab::Redis.with do |redis| + redis.zcount(USER_ACTIVITY_SET_KEY, from.to_i, to.to_i) + end + end + + def limit(page) + [offset(page), ACTIVITIES_PER_PAGE] + end + + def total_pages(count) + (count.to_f / ACTIVITIES_PER_PAGE).ceil + end + + def last_page?(page, count) + page >= total_pages(count) + end + + def offset(page) + (page - 1) * ACTIVITIES_PER_PAGE + end +end -- cgit v1.2.3 From 380e40fee30d836e6dffb1e956df39033d43a671 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 12 Apr 2017 16:13:24 +0100 Subject: Remove unused user activities code --- .../20161007073613_create_user_activities.rb | 24 ++-------------------- .../20161128170531_drop_user_activities_table.rb | 16 +-------------- 2 files changed, 3 insertions(+), 37 deletions(-) (limited to 'db') diff --git a/db/migrate/20161007073613_create_user_activities.rb b/db/migrate/20161007073613_create_user_activities.rb index 4239cebd8f6..1d694e777a1 100644 --- a/db/migrate/20161007073613_create_user_activities.rb +++ b/db/migrate/20161007073613_create_user_activities.rb @@ -1,27 +1,7 @@ class CreateUserActivities < ActiveRecord::Migration - # 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 = '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 - # 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! + DOWNTIME = false + # This migration is a no-op. It just exists to match EE. def change - create_table :user_activities do |t| - t.belongs_to :user, index: { unique: true }, foreign_key: { on_delete: :cascade } - t.datetime :last_activity_at, null: false - end end end diff --git a/db/post_migrate/20161128170531_drop_user_activities_table.rb b/db/post_migrate/20161128170531_drop_user_activities_table.rb index 3ece0722821..00bc0c73015 100644 --- a/db/post_migrate/20161128170531_drop_user_activities_table.rb +++ b/db/post_migrate/20161128170531_drop_user_activities_table.rb @@ -1,23 +1,9 @@ -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class DropUserActivitiesTable < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers DOWNTIME = false - # 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! - + # This migration is a no-op. It just exists to match EE. def change - drop_table :user_activities end end -- cgit v1.2.3 From a4e2a84f990641f7b067adf16261928084dac5f9 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 12 Apr 2017 16:16:13 +0100 Subject: Make downtime_check happy --- db/migrate/20160713222618_add_usage_ping_to_application_settings.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'db') diff --git a/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb b/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb index c7c5cdf7a56..a7f76cc626e 100644 --- a/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb +++ b/db/migrate/20160713222618_add_usage_ping_to_application_settings.rb @@ -1,6 +1,8 @@ class AddUsagePingToApplicationSettings < ActiveRecord::Migration include Gitlab::Database::MigrationHelpers + DOWNTIME = false + def change add_column :application_settings, :usage_ping_enabled, :boolean, default: true, null: false end -- cgit v1.2.3 From 1c6710e235e00d74b33c3712e2a981a8891d2a82 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 19 Apr 2017 10:15:35 +0200 Subject: Add migration to remove orphaned notification settings --- ...18103908_delete_orphan_notification_settings.rb | 24 ++++++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170418103908_delete_orphan_notification_settings.rb (limited to 'db') diff --git a/db/migrate/20170418103908_delete_orphan_notification_settings.rb b/db/migrate/20170418103908_delete_orphan_notification_settings.rb new file mode 100644 index 00000000000..e4b9cf65936 --- /dev/null +++ b/db/migrate/20170418103908_delete_orphan_notification_settings.rb @@ -0,0 +1,24 @@ +class DeleteOrphanNotificationSettings < ActiveRecord::Migration + DOWNTIME = false + + def up + execute("DELETE FROM notification_settings WHERE EXISTS (SELECT true FROM (#{orphan_notification_settings}) AS ns WHERE ns.id = notification_settings.id)") + end + + def down + # This is a no-op method to make the migration reversible. + # If someone is trying to rollback for other reasons, we should not throw an Exception. + # raise ActiveRecord::IrreversibleMigration + end + + def orphan_notification_settings + <<-SQL + SELECT notification_settings.id + FROM notification_settings + LEFT OUTER JOIN namespaces + ON namespaces.id = notification_settings.source_id + WHERE notification_settings.source_type = 'Namespace' + AND namespaces.id IS NULL + SQL + end +end diff --git a/db/schema.rb b/db/schema.rb index 5689f7331dc..26ec6367bd0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170408033905) do +ActiveRecord::Schema.define(version: 20170418103908) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.3 From 3f0054a88c84ef5631ee82c1cc9bc985c2eea58b Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 18 Apr 2017 20:00:35 -0700 Subject: Add unique index for note_id to system note metadata table In issue 1, the sequential scan was taking 250+ ms. --- .../20170419001229_add_index_to_system_note_metadata.rb | 17 +++++++++++++++++ db/schema.rb | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170419001229_add_index_to_system_note_metadata.rb (limited to 'db') diff --git a/db/migrate/20170419001229_add_index_to_system_note_metadata.rb b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb new file mode 100644 index 00000000000..c68fd920fff --- /dev/null +++ b/db/migrate/20170419001229_add_index_to_system_note_metadata.rb @@ -0,0 +1,17 @@ +class AddIndexToSystemNoteMetadata < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + # MySQL automatically creates an index on a foreign-key constraint; PostgreSQL does not + add_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql? + end + + def down + remove_concurrent_index :system_note_metadata, :note_id, unique: true if Gitlab::Database.postgresql? + end +end diff --git a/db/schema.rb b/db/schema.rb index 26ec6367bd0..e84fd90a4cd 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: 20170418103908) do +ActiveRecord::Schema.define(version: 20170419001229) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1140,6 +1140,8 @@ ActiveRecord::Schema.define(version: 20170418103908) do t.datetime "updated_at", null: false end + add_index "system_note_metadata", ["note_id"], name: "index_system_note_metadata_on_note_id", unique: true, using: :btree + create_table "taggings", force: :cascade do |t| t.integer "tag_id" t.integer "taggable_id" -- cgit v1.2.3