Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You mean on the from side? Yes, just drop the existing index and create a unique index. You can do that within the same transaction.

Postgres already requires the pointed to relation to have a unique index:

    => create table foo (id int); -- No unique index here.
    CREATE TABLE
    => create index foo_id on foo(id);
    CREATE INDEX
    => create table bar(foo int references foo(id));
    ERROR:  there is no unique constraint matching given keys for referenced table "foo"


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: