game-data/db/migrations/0001_add_initial_tables.rb

41 lines
1.0 KiB
Ruby
Raw Normal View History

Sequel.migration do
up do
create_table(:hardware) do
primary_key :id
String :name, null: false
String :type, null: false
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
end
create_table(:benchmarks) do
primary_key :id
String :name, null: false
String :description
String :scoring, null: false
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
end
create_table(:results) do
primary_key :id
String :name, null: false
String :score, null: false
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
end
alter_table(:results) do
add_foreign_key :hardware_id, :hardware
add_foreign_key :benchmark_id, :benchmarks
end
end
down do
drop_table(:hardware)
drop_table(:benchmarks)
drop_table(:results)
end
end