diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-06-01 08:32:40 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-06-01 08:32:40 +0300 |
commit | 272b8dca80eddfcf40933ad5295e9d11f8b1fa93 (patch) | |
tree | 9cafcf1ce1643fbfa1d3237e1af3a569f48d8459 /db | |
parent | 0e22b50df8b269ccae32ab68b9ba26e7eea861b0 (diff) | |
parent | 50fda506e3bc93af47c8ebcbfc7d38c7ae55467d (diff) |
Merge branch 'master' into per-project-pipeline-iid
Diffstat (limited to 'db')
5 files changed, 94 insertions, 2 deletions
diff --git a/db/migrate/20180408143354_rename_users_rss_token_to_feed_token.rb b/db/migrate/20180408143354_rename_users_rss_token_to_feed_token.rb new file mode 100644 index 00000000000..007cbebaf1b --- /dev/null +++ b/db/migrate/20180408143354_rename_users_rss_token_to_feed_token.rb @@ -0,0 +1,15 @@ +class RenameUsersRssTokenToFeedToken < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + rename_column_concurrently :users, :rss_token, :feed_token + end + + def down + cleanup_concurrent_column_rename :users, :feed_token, :rss_token + end +end diff --git a/db/migrate/20180515005612_add_squash_to_merge_requests.rb b/db/migrate/20180515005612_add_squash_to_merge_requests.rb new file mode 100644 index 00000000000..f526b45bd4b --- /dev/null +++ b/db/migrate/20180515005612_add_squash_to_merge_requests.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 AddSquashToMergeRequests < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = false + + def up + unless column_exists?(:merge_requests, :squash) + add_column_with_default :merge_requests, :squash, :boolean, default: false, allow_null: false + end + end + + def down + remove_column :merge_requests, :squash if column_exists?(:merge_requests, :squash) + end +end diff --git a/db/post_migrate/20180408143355_cleanup_users_rss_token_rename.rb b/db/post_migrate/20180408143355_cleanup_users_rss_token_rename.rb new file mode 100644 index 00000000000..bff83379087 --- /dev/null +++ b/db/post_migrate/20180408143355_cleanup_users_rss_token_rename.rb @@ -0,0 +1,13 @@ +class CleanupUsersRssTokenRename < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def up + cleanup_concurrent_column_rename :users, :rss_token, :feed_token + end + + def down + rename_column_concurrently :users, :feed_token, :rss_token + end +end diff --git a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb new file mode 100644 index 00000000000..0282688fa40 --- /dev/null +++ b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb @@ -0,0 +1,44 @@ +class MigrateRemainingMrMetricsPopulatingBackgroundMigration < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 5_000 + MIGRATION = 'PopulateMergeRequestMetricsWithEventsData' + DELAY_INTERVAL = 10.minutes + + disable_ddl_transaction! + + class MergeRequest < ActiveRecord::Base + self.table_name = 'merge_requests' + + include ::EachBatch + end + + def up + # Perform any ongoing background migration that might still be running. This + # avoids scheduling way too many of the same jobs on self-hosted instances + # if they're updating GitLab across multiple versions. The "Take one" + # migration was executed on 10.4 on + # SchedulePopulateMergeRequestMetricsWithEventsData. + Gitlab::BackgroundMigration.steal(MIGRATION) + + metrics_not_exists_clause = <<~SQL + NOT EXISTS (SELECT 1 FROM merge_request_metrics + WHERE merge_request_metrics.merge_request_id = merge_requests.id) + SQL + + relation = MergeRequest.where(metrics_not_exists_clause) + + # We currently have ~400_000 MR records without metrics on GitLab.com. + # This means it'll schedule ~80 jobs (5000 MRs each) with a 10 minutes gap, + # so this should take ~14 hours for all background migrations to complete. + # + queue_background_migration_jobs_by_range_at_intervals(relation, + MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE) + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 359d25dafb5..53bdb084eea 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1219,6 +1219,7 @@ ActiveRecord::Schema.define(version: 20180529093006) do t.integer "latest_merge_request_diff_id" t.string "rebase_commit_sha" t.boolean "allow_maintainer_to_push" + t.boolean "squash", default: false, null: false end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree @@ -2083,9 +2084,9 @@ ActiveRecord::Schema.define(version: 20180529093006) do t.date "last_activity_on" t.boolean "notified_of_own_activity" t.string "preferred_language" - t.string "rss_token" t.integer "theme_id", limit: 2 t.integer "accepted_term_id" + t.string "feed_token" end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree @@ -2093,12 +2094,12 @@ ActiveRecord::Schema.define(version: 20180529093006) do add_index "users", ["created_at"], name: "index_users_on_created_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", ["feed_token"], name: "index_users_on_feed_token", using: :btree add_index "users", ["ghost"], name: "index_users_on_ghost", using: :btree add_index "users", ["incoming_email_token"], name: "index_users_on_incoming_email_token", using: :btree add_index "users", ["name"], name: "index_users_on_name", using: :btree add_index "users", ["name"], name: "index_users_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree - add_index "users", ["rss_token"], name: "index_users_on_rss_token", using: :btree add_index "users", ["state"], name: "index_users_on_state", using: :btree add_index "users", ["username"], name: "index_users_on_username", using: :btree add_index "users", ["username"], name: "index_users_on_username_trigram", using: :gin, opclasses: {"username"=>"gin_trgm_ops"} |