2013-07-24 15:43:41 +01:00
|
|
|
class CreatePlatformArchSettings < ActiveRecord::Migration
|
|
|
|
|
|
|
|
def up
|
|
|
|
create_table :platform_arch_settings do |t|
|
2014-01-21 04:51:49 +00:00
|
|
|
t.integer :platform_id, null: false
|
|
|
|
t.integer :arch_id, null: false
|
|
|
|
t.integer :time_living, null: false
|
2013-07-24 15:43:41 +01:00
|
|
|
t.boolean :default
|
|
|
|
t.timestamps
|
|
|
|
end
|
2014-01-21 04:51:49 +00:00
|
|
|
add_index :platform_arch_settings, [:platform_id, :arch_id], unique: true
|
2013-07-24 15:43:41 +01:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
arch_ids = Arch.where(name: %w(i586 x86_64)).pluck(:id)
|
2013-07-24 15:43:41 +01:00
|
|
|
Platform.main.each do |platform|
|
|
|
|
arch_ids.each do |arch_id|
|
|
|
|
platform.platform_arch_settings.create(
|
|
|
|
:arch_id => arch_id,
|
|
|
|
:default => true,
|
|
|
|
:time_living => PlatformArchSetting::DEFAULT_TIME_LIVING / 60
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2013-07-25 11:02:47 +01:00
|
|
|
drop_table :platform_arch_settings
|
2013-07-24 15:43:41 +01:00
|
|
|
end
|
|
|
|
end
|