[Issue #5] - Reworked app to better organize results with their corresponding tests
This commit is contained in:
31
db/migrations/0003_add_tests_table.rb
Normal file
31
db/migrations/0003_add_tests_table.rb
Normal file
@ -0,0 +1,31 @@
|
||||
Sequel.migration do
|
||||
|
||||
up do
|
||||
# create tests table
|
||||
create_table(:tests) do
|
||||
primary_key :id
|
||||
String :date_tag, null: false
|
||||
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
|
||||
# add foreign keys to tests table
|
||||
alter_table(:tests) do
|
||||
add_foreign_key(:benchmark_id, :benchmarks, null: false)
|
||||
add_foreign_key(:hardware_id, :hardware, null: false)
|
||||
end
|
||||
|
||||
# add the test ID link to results table; remove old links to hardware and benchmarks tables
|
||||
alter_table(:results) do
|
||||
add_foreign_key(:test_id, :tests, null: false)
|
||||
drop_column(:benchmark_id)
|
||||
drop_column(:hardware_id)
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
drop_column(:results, :test_id)
|
||||
drop_table(:tests)
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user