All checks were successful
CI / Test (1.24) (push) Successful in -25m5s
CI / Test (1.25) (push) Successful in -24m57s
CI / Build (push) Successful in -26m5s
CI / Lint (push) Successful in -25m51s
Integration Tests / Integration Tests (push) Successful in -25m42s
Release / Build and Release (push) Successful in -24m39s
* Introduce `--flatten-schema` flag to convert, merge, and split commands. * Modify database writing functions to support flattened schema names. * Update template functions to handle schema.table naming convention. * Enhance PostgreSQL writer to utilize flattened schema in generated SQL. * Update tests to ensure compatibility with new flattening feature. * Dependencies updated for improved functionality.
39 lines
1.1 KiB
Cheetah
39 lines
1.1 KiB
Cheetah
{{/* Base constraint template */}}
|
|
{{- define "constraint_base" -}}
|
|
ALTER TABLE {{qual_table_raw .SchemaName .TableName}}
|
|
ADD CONSTRAINT {{.ConstraintName}}
|
|
{{block "constraint_definition" .}}{{end}};
|
|
{{- end -}}
|
|
|
|
{{/* Drop constraint with check */}}
|
|
{{- define "drop_constraint_safe" -}}
|
|
DO $$
|
|
BEGIN
|
|
IF EXISTS (
|
|
SELECT 1 FROM information_schema.table_constraints
|
|
WHERE table_schema = '{{.SchemaName}}'
|
|
AND table_name = '{{.TableName}}'
|
|
AND constraint_name = '{{.ConstraintName}}'
|
|
) THEN
|
|
ALTER TABLE {{qual_table_raw .SchemaName .TableName}}
|
|
DROP CONSTRAINT {{.ConstraintName}};
|
|
END IF;
|
|
END;
|
|
$$;
|
|
{{- end -}}
|
|
|
|
{{/* Add constraint with existence check */}}
|
|
{{- define "add_constraint_safe" -}}
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (
|
|
SELECT 1 FROM information_schema.table_constraints
|
|
WHERE table_schema = '{{.SchemaName}}'
|
|
AND table_name = '{{.TableName}}'
|
|
AND constraint_name = '{{.ConstraintName}}'
|
|
) THEN
|
|
{{template "constraint_base" .}}
|
|
END IF;
|
|
END;
|
|
$$;
|
|
{{- end -}} |