clear
clear copied to clipboard
Creating a UNIQUE constraint on multiple columns?
can Clear support unique constraints on multiple columns? for example:
CREATE TABLE table (
c1 data_type,
c2 data_type,
c3 data_type,
UNIQUE (c2, c3)
);
@jubishop yes, you can create it with Clear migrations
For example:
class CreateUsers
include Clear::Migration
def change(direction)
direction.up do
create_table(:users) do |t|
t.column :provider, :string, null: false
t.column :provider_id, :integer, null: false
t.column :name, :string
t.column :created_at, :timestamp
t.column :synced_at, :timestamp, null: false
t.index [:provider, :provider_id], using: :btree, unique: true
end
end
direction.down do
execute("DROP TABLE users")
end
end
end
https://clear.gitbook.io/project/migrations/call-migration-script