diff options
Diffstat (limited to 'db/post_migrate/20171114104051_remove_empty_fork_networks.rb')
-rw-r--r-- | db/post_migrate/20171114104051_remove_empty_fork_networks.rb | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb deleted file mode 100644 index 76862cccf60..00000000000 --- a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb +++ /dev/null @@ -1,36 +0,0 @@ -class RemoveEmptyForkNetworks < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BATCH_SIZE = 10_000 - - class MigrationForkNetwork < ActiveRecord::Base - include EachBatch - - self.table_name = 'fork_networks' - end - - class MigrationForkNetworkMembers < ActiveRecord::Base - self.table_name = 'fork_network_members' - end - - disable_ddl_transaction! - - def up - say 'Deleting empty ForkNetworks in batches' - - has_members = MigrationForkNetworkMembers - .where('fork_network_members.fork_network_id = fork_networks.id') - .select(1) - MigrationForkNetwork.where('NOT EXISTS (?)', has_members) - .each_batch(of: BATCH_SIZE) do |networks| - deleted = networks.delete_all - - say "Deleted #{deleted} rows in batch" - end - end - - def down - # nothing - end -end |