12 lines
419 B
Cheetah
12 lines
419 B
Cheetah
DO {{dollar_delimiter}}
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1 FROM information_schema.table_constraints
|
|
WHERE table_schema = {{quote .SchemaName}}
|
|
AND table_name = {{quote .TableName}}
|
|
AND constraint_name = {{quote .ConstraintName}}
|
|
) THEN
|
|
ALTER TABLE {{qual_table .SchemaName .TableName}} ADD CONSTRAINT {{quote_ident .ConstraintName}} CHECK ({{.Expression}});
|
|
END IF;
|
|
END;
|
|
{{dollar_delimiter}}; |