DROP TABLE bla CASCADE;
DROP TABLE foo CASCADE;

CREATE TABLE foo (
  fid SERIAL PRIMARY KEY,
  stuff TEXT DEFAULT ''::text NOT NULL
);

CREATE TABLE bla (
  bid SERIAL PRIMARY KEY,
  stuff TEXT NOT NULL
);

-- this should amount to a constraint...
CREATE UNIQUE INDEX foo_stuff_uniq ON foo USING btree (stuff);

-- BUT:
-- 1. it does not appear anywhere
--    in information_schema.table_constraints
--    (nor in pg_catalog.pg_constraint, but only in pg_catalog.pg_index(es))
-- 2. foo_bla unique_constraint_name (next) is empty
--    in information_schema.referential_constraints

-- however after this one: (uncomment to test)
-- ALTER TABLE foo ADD CONSTRAINT foo_stuff_uniq2 UNIQUE(stuff);
-- it appears both as a constraint AND an index, and
-- the unique_constraint_name is not empty.

ALTER TABLE ONLY bla
  ADD CONSTRAINT "bla_foo" FOREIGN KEY (stuff) REFERENCES foo(stuff);

SELECT *
FROM information_schema.table_constraints
WHERE constraint_schema = 'public';

SELECT *
FROM information_schema.referential_constraints;
