- migration writer now emits unique constraints (direct apply and live diff previously dropped them); idempotent via the existing DO block - unique constraint adopts a same-named model unique index with ADD CONSTRAINT ... UNIQUE USING INDEX instead of building a second index - dbml reader names unnamed unique indexes ukey_<table>_<cols> to match the unique constraint naming - foreign key deferral: Constraint.Deferrable/InitiallyDeferred are *bool (nil = unspecified, never diffed); writers emit DEFERRABLE, DEFERRABLE INITIALLY DEFERRED and NOT DEFERRABLE; live reader reads condeferrable and condeferred; dbml reader/writer support deferrable and initially deferred - tests and README/naming docs updated
10 lines
390 B
Cheetah
10 lines
390 B
Cheetah
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
|
DROP CONSTRAINT IF EXISTS {{quote_ident .ConstraintName}};
|
|
|
|
ALTER TABLE {{qual_table .SchemaName .TableName}}
|
|
ADD CONSTRAINT {{quote_ident .ConstraintName}}
|
|
FOREIGN KEY ({{.SourceColumns}})
|
|
REFERENCES {{qual_table .TargetSchema .TargetTable}} ({{.TargetColumns}})
|
|
ON DELETE {{.OnDelete}}
|
|
ON UPDATE {{.OnUpdate}}
|
|
{{.Deferral}}; |