Closed antipopp closed 3 years ago
Well, my bad. Apparently the on_update
or on_delete
tag goes (quite obviously now that I know) on the FK field (the one that actually generates the FK column). Like this:
type DossierRule struct {
ID string `json:"id"`
Description string `json:"description"`
DossierTypeName string `json:"dossier_type_fk" pg:"on_delete:CASCADE"`
DossierType DossierType `pg:"rel:has-one"`
}
Maybe the docs could be clearer when explaining FK constraints.
Expected Behavior
When creating a model that has
on_update
oron_delete
tags I would expect that the resulting table would have these options set for the respective foreign key.Current Behavior
It doesn't set the foreign key with
on_delete
oron_update
options.Code example