Skip to content

Commit 56f7263

Browse files
committed
constraint check fixed
1 parent f7c5352 commit 56f7263

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/migrations/postgres/PostgresMigrations.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,13 @@ export default abstract class PostgresMigrations extends Migrations {
6363
const indexes = r.rows;
6464

6565
text = `
66-
SELECT
67-
tc.constraint_name as "name"
68-
FROM information_schema.table_constraints AS tc
69-
JOIN information_schema.key_column_usage AS kcu
70-
ON tc.constraint_name = kcu.constraint_name
71-
AND tc.table_schema = kcu.table_schema
72-
JOIN information_schema.constraint_column_usage AS ccu
73-
ON ccu.constraint_name = tc.constraint_name
74-
WHERE
75-
tc.constraint_type <> 'FOREIGN KEY'
76-
AND tc.table_schema = $1`;
66+
SELECT con.conName as "name"
67+
FROM pg_catalog.pg_constraint con
68+
INNER JOIN pg_catalog.pg_class rel
69+
ON rel.oid = con.conRelId
70+
INNER JOIN pg_catalog.pg_namespace nsp
71+
ON nsp.oid = conNamespace
72+
WHERE nsp.nspName = $1`;
7773

7874
r = await this.executeQuery({ text, values });
7975
const constraints = r.rows;

0 commit comments

Comments
 (0)