diff options
author | Nick Thomas <nick@gitlab.com> | 2019-07-01 12:23:25 +0100 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-07-02 09:35:03 +0100 |
commit | cfe31f992a12c95570891b8cca8747589c6c6228 (patch) | |
tree | d89296a511b093b7216a4aca3a933234c9047865 /db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb | |
parent | 6d867cad918d80216908b68dba7e785997871ac7 (diff) | |
download | gitlab-ce-cfe31f992a12c95570891b8cca8747589c6c6228.tar.gz |
Squash old migrations
Use the `squasher` gem to squash migrations older than the start of 2018
Diffstat (limited to 'db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb')
-rw-r--r-- | db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb deleted file mode 100644 index 908b122c659..00000000000 --- a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb +++ /dev/null @@ -1,37 +0,0 @@ -class AddForeignKeyToMergeRequests < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' - include ::EachBatch - end - - def up - scope = <<-SQL.strip_heredoc - head_pipeline_id IS NOT NULL - AND NOT EXISTS ( - SELECT 1 FROM ci_pipelines - WHERE ci_pipelines.id = merge_requests.head_pipeline_id - ) - SQL - - MergeRequest.where(scope).each_batch(of: 1000) do |merge_requests| - merge_requests.update_all(head_pipeline_id: nil) - end - - unless foreign_key_exists?(:merge_requests, column: :head_pipeline_id) - add_concurrent_foreign_key(:merge_requests, :ci_pipelines, - column: :head_pipeline_id, on_delete: :nullify) - end - end - - def down - if foreign_key_exists?(:merge_requests, column: :head_pipeline_id) - remove_foreign_key(:merge_requests, column: :head_pipeline_id) - end - end -end |