8000 Merge pull request #569 from supabase/fix/allow-deleting-of-check-con… · shenmirs/postgres-meta@ec14254 · GitHub
[go: up one dir, main page]

Skip to content

Commit ec14254

Browse files
authored
Merge pull request supabase#569 from supabase/fix/allow-deleting-of-check-constraints
fix: allow deletion of check constraints
2 parents 2e54b2d + dd2af8c commit ec14254

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/lib/PostgresMetaColumns.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ COMMIT;`
225225
is_nullable?: boolean
226226
is_unique?: boolean
227227
comment?: string
228-
check?: string
228+
check?: string | null
229229
}
230230
): Promise<PostgresMetaResult<PostgresColumn>> {
231231
const { data: old, error } = await this.retrieve({ id })
@@ -353,9 +353,12 @@ BEGIN
353353
)} DROP CONSTRAINT %s', v_conname);
354354
END IF;
355355
356+
${
357+
check !== null
358+
? `
356359
ALTER TABLE ${ident(old!.schema)}.${ident(old!.table)} ADD CONSTRAINT ${ident(
357-
`${old!.table}_${old!.name}_check`
358-
)} CHECK (${check});
360+
`${old!.table}_${ 8924 old!.name}_check`
361+
)} CHECK (${check});
359362
360363
SELECT conkey into v_conkey FROM pg_constraint WHERE conname = ${literal(
361364
`${old!.table}_${old!.name}_check`
@@ -366,6 +369,9 @@ BEGIN
366369
ASSERT v_conkey[1] = ${literal(
367370
old!.ordinal_position
368371
)}, 'error creating column constraint: check condition cannot refer to other columns';
372+
`
373+
: ''
374+
}
369375
END
370376
$$;
371377
`

0 commit comments

Comments
 (0)
0