File tree 1 file changed +13
-2
lines changed 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 337
337
DO $$
338
338
DECLARE
339
339
v_conname name;
340
+ v_conkey int2[];
340
341
BEGIN
341
342
SELECT conname into v_conname FROM pg_constraint WHERE
342
343
contype = 'c'
@@ -353,8 +354,18 @@ BEGIN
353
354
END IF;
354
355
355
356
ALTER TABLE ${ ident ( old ! . schema ) } .${ ident ( old ! . table ) } ADD CONSTRAINT ${ ident (
356
- old ! . table
357
- ) } _${ ident ( old ! . name ) } _check CHECK (${ check } );
357
+ `${ old ! . table } _${ old ! . name } _check`
358
+ ) } CHECK (${ check } );
359
+
360
+ SELECT conkey into v_conkey FROM pg_constraint WHERE conname = ${ literal (
361
+ `${ old ! . table } _${ old ! . name } _check`
362
+ ) } ;
363
+
364
+ ASSERT v_conkey IS NOT NULL, 'error creating column constraint: check condition must refer to this column';
365
+ ASSERT cardinality(v_conkey) = 1, 'error creating column constraint: check condition cannot refer to multiple columns';
366
+ ASSERT v_conkey[1] = ${ literal (
367
+ old ! . ordinal_position
368
+ ) } , 'error creating column constraint: check condition cannot refer to other columns';
358
369
END
359
370
$$;
360
371
`
You can’t perform that action at this time.
0 commit comments