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