Skip to content

Commit

Permalink
Migrate data from reserved table to host_storages
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Aug 25, 2016
1 parent 8fd3ff0 commit 5ba85c6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions db/migrate/20160713141244_upgrade_host_storage_from_reserved.rb
@@ -0,0 +1,23 @@
class UpgradeHostStorageFromReserved < ActiveRecord::Migration[5.0]
class HostStorage < ActiveRecord::Base
include ReservedMixin
include MigrationStubHelper
end

def up
say_with_time("Migrate data from reserved table to host_storages") do
HostStorage.includes(:reserved_rec).each do |hs|
hs.reserved_hash_migrate(:ems_ref)
end
end
end

def down
say_with_time("Migrate data from host_storages to reserved table") do
HostStorage.includes(:reserved_rec).each do |hs|
hs.reserved_hash_set(:ems_ref, hs.ems_ref)
hs.save!
end
end
end
end

0 comments on commit 5ba85c6

Please sign in to comment.