Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate data from reserved table to host_storages
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
db/migrate/20160713141244_upgrade_host_storage_from_reserved.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |