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