Started adding test model/routes/views; removed a bit of the old paradigm with tying results directly to hardware
This commit is contained in:
39
db/migrations/0003_add_tests_table.rb
Normal file
39
db/migrations/0003_add_tests_table.rb
Normal file
@ -0,0 +1,39 @@
|
||||
Sequel.migration do
|
||||
|
||||
up do
|
||||
# create tests table
|
||||
create_table(:tests) do
|
||||
primary_key :id
|
||||
foreign_key :hardware_id, :hardware
|
||||
String :name, null: false
|
||||
String :description
|
||||
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
|
||||
# create many-to-many table between tests and benchmarks
|
||||
create_table(:benchmarks_tests) do
|
||||
primary_key :id
|
||||
foreign_key :benchmark_id, :benchmarks
|
||||
foreign_key :test_id, :tests
|
||||
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
|
||||
# modify results table to integrate with the new tests table
|
||||
alter_table(:results) do
|
||||
drop_foreign_key :hardware_id
|
||||
add_foreign_key :test_id, :tests
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
alter_table(:results) do
|
||||
drop_foreign_key :test_id
|
||||
add_foreign_key :hardware_id, :hardware
|
||||
end
|
||||
drop_table(:benchmarks_tests)
|
||||
drop_table(:tests)
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user