codegen: add generator for soft-deletion

This commit is contained in:
2026-09-19 21:36:31 -07:00
parent 9d4a1eab10
commit b064948d24
4 changed files with 89 additions and 1 deletions

View File

@@ -61,3 +61,18 @@ func (t Table) HasAutoTimestamps() (hasCreatedAt bool, hasUpdatedAt bool) {
}
return
}
// HasSoftDelete reports whether this table supports soft-deletion, i.e., whether it has both
// an "is_deleted" and a "deleted_at" column.
func (t Table) HasSoftDelete() bool {
var hasIsDeleted, hasDeletedAt bool
for _, c := range t.Columns {
if c.Name == "is_deleted" && c.Type == "integer" {
hasIsDeleted = true
}
if c.Name == "deleted_at" && c.Type == "integer" {
hasDeletedAt = true
}
}
return hasIsDeleted && hasDeletedAt
}