diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-16 16:05:03 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-16 16:05:03 +0100 |
commit | d2d64393ed0e64fd63981d5d02fee52fa16a081c (patch) | |
tree | f3e105279a5c0c77cd09a2d7d5757bdf21536d8e /db | |
parent | d64183e1fa26ab77107e3a2a20be1fe4df3a1875 (diff) | |
parent | b7aae9a6cde71dfc448d8da34ebe38104068387c (diff) | |
download | gitlab-ce-d2d64393ed0e64fd63981d5d02fee52fa16a081c.tar.gz |
Merge remote-tracking branch 'origin/master' into chat-name-authorize
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb | 5 | ||||
-rw-r--r-- | db/migrate/20161103191444_add_sidekiq_throttling_to_application_settings.rb | 31 | ||||
-rw-r--r-- | db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb (renamed from db/migrate/20161011222551_remove_inactive_jira_service_properties.rb) | 0 | ||||
-rw-r--r-- | db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb | 49 | ||||
-rw-r--r-- | db/schema.rb | 5 |
5 files changed, 85 insertions, 5 deletions
diff --git a/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb b/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb index fad62d716b3..4da5ec9bd28 100644 --- a/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb +++ b/db/migrate/20160914131004_only_allow_merge_if_all_discussions_are_resolved.rb @@ -5,10 +5,7 @@ class OnlyAllowMergeIfAllDiscussionsAreResolved < ActiveRecord::Migration disable_ddl_transaction! def up - add_column_with_default(:projects, - :only_allow_merge_if_all_discussions_are_resolved, - :boolean, - default: false) + add_column :projects, :only_allow_merge_if_all_discussions_are_resolved, :boolean end def down diff --git a/db/migrate/20161103191444_add_sidekiq_throttling_to_application_settings.rb b/db/migrate/20161103191444_add_sidekiq_throttling_to_application_settings.rb new file mode 100644 index 00000000000..e644a174964 --- /dev/null +++ b/db/migrate/20161103191444_add_sidekiq_throttling_to_application_settings.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 AddSidekiqThrottlingToApplicationSettings < 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, :sidekiq_throttling_enabled, :boolean, default: false + add_column :application_settings, :sidekiq_throttling_queues, :string + add_column :application_settings, :sidekiq_throttling_factor, :decimal + end +end diff --git a/db/migrate/20161011222551_remove_inactive_jira_service_properties.rb b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb index 319d86ac159..319d86ac159 100644 --- a/db/migrate/20161011222551_remove_inactive_jira_service_properties.rb +++ b/db/post_migrate/20161011222551_remove_inactive_jira_service_properties.rb diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb new file mode 100644 index 00000000000..bea1cfa4c5d --- /dev/null +++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb @@ -0,0 +1,49 @@ +class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + BATCH_SIZE = 1000 + DOWNTIME = false + + # This migration is idempotent and there's no sense in throwing away the + # partial result if it's interrupted + disable_ddl_transaction! + + def up + projects = Arel::Table.new(:projects) + namespaces = Arel::Table.new(:namespaces) + + finder = + projects. + join(namespaces, Arel::Nodes::InnerJoin). + on(projects[:namespace_id].eq(namespaces[:id])). + where(projects[:visibility_level].gt(namespaces[:visibility_level])). + project(projects[:id]). + take(BATCH_SIZE) + + # MySQL requires a derived table to perform this query + nested_finder = + projects. + from(finder.as("AS projects_inner")). + project(projects[:id]) + + valuer = + namespaces. + where(namespaces[:id].eq(projects[:namespace_id])). + project(namespaces[:visibility_level]) + + # Update matching rows until none remain. The finder contains a limit. + loop do + updater = Arel::UpdateManager.new(ActiveRecord::Base). + table(projects). + set(projects[:visibility_level] => Arel::Nodes::SqlLiteral.new("(#{valuer.to_sql})")). + where(projects[:id].in(nested_finder)) + + num_updated = connection.exec_update(updater.to_sql, self.class.name, []) + break if num_updated == 0 + end + end + + def down + # no-op + end +end diff --git a/db/schema.rb b/db/schema.rb index 1c1a7a37096..3688df3a238 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -98,6 +98,9 @@ ActiveRecord::Schema.define(version: 20161113184239) 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 @@ -927,7 +930,7 @@ ActiveRecord::Schema.define(version: 20161113184239) do t.boolean "has_external_wiki" t.boolean "lfs_enabled" t.text "description_html" - t.boolean "only_allow_merge_if_all_discussions_are_resolved", default: false, null: false + t.boolean "only_allow_merge_if_all_discussions_are_resolved" end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree |