mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 09:45:11 +02:00
parent
5fdc1938af
commit
5a533e09bf
44 changed files with 1027 additions and 375 deletions
23
db/migrate/20170423225333_add_zone_to_prices.rb
Normal file
23
db/migrate/20170423225333_add_zone_to_prices.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
class AddZoneToPrices < ActiveRecord::Migration
|
||||
def up
|
||||
add_reference :prices, :zone, index: true
|
||||
add_foreign_key :prices, :zones
|
||||
assign_zone_to_current_prices
|
||||
change_column :prices, :zone_id, :integer, null: false
|
||||
remove_column :prices, :category, :string
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assign_zone_to_current_prices
|
||||
Billing::Price.all.each do |price|
|
||||
zone = DNS::Zone.find_by!(origin: price.category)
|
||||
price.zone = zone
|
||||
price.save!
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue