These are my migrations for the table users_hobbies:
Create:
Sequel.migration do
up do
create_table :users_hobbies do
Integer :user_id
Integer :hobby_id
end
end
down do
drop_table :users_hobbies
end
end
Alter:
Sequel.migration do
up do
alter_table :users_hobbies do
unique [:user_id, :hobby_id]
end
end
down do
end
end
When I did the second migration I got the following error, any ideas?
NoMethodError: undefined method 'unique' for #<Sequel::Schema::AlterTableGenerator:0x007fba1aea7c30>
unique
is only defined in create_table
blocks. In alter_table
blocks, you need to use add_unique_constraint
.