eshumskaya
eshumskaya

Reputation: 1

Unique constraint with FluentMigrator

How can I add "lower(title)" in creation of my table with FluentMigrator, I want to have case insensetive unique constraint in postgre

Upvotes: 0

Views: 1926

Answers (1)

Patrick
Patrick

Reputation: 32199

Insofar as I know you cannot solve this in the table definition as the UNIQUE constraint will only accept a column name. You could create an index on the title column with a UNIQUE clause, which effectively does what you want:

CREATE UNIQUE INDEX title_unique ON table_name (lower(title));

This of course also gives you an explicit index on title, which is required to enforce the constraint anyway.

Upvotes: 1

Related Questions