DROP VIEW IF EXISTS V_UNIQUE_INDEXES;
CREATE VIEW V_UNIQUE_INDEXES as
SELECT idx.indrelid::regclass::varchar as TableName,
       i.relname as IndexName,
       pg_get_indexdef(idx.indexrelid, generate_subscripts(idx.indkey, 1) + 1, true) as indkey_names
FROM   pg_index as idx
JOIN   pg_class as i
ON     i.oid = idx.indexrelid
JOIN   pg_am as am
ON     i.relam = am.oid
JOIN   pg_namespace as ns
ON     ns.oid = i.relnamespace
AND    ns.nspname = ANY(current_schemas(false))
where idx.indisunique='t' and idx.indisprimary='f';