refactor: create helper functions in model generator
All checks were successful
CI / build-docker (push) Successful in 4s
CI / build-docker-bootstrap (push) Has been skipped
CI / release-test (push) Successful in 2m25s

This commit is contained in:
wispem-wantex
2026-01-31 18:25:53 -08:00
parent cb8edd74c0
commit b96ab19bc2
2 changed files with 21 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
package schema
import "strings"
// Column represents a single column in a table.
type Column struct {
TableName string `db:"table_name"`
@@ -20,6 +22,10 @@ func (c Column) IsNullableForeignKey() bool {
return !c.IsNotNull && !c.IsPrimaryKey && c.IsForeignKey
}
func (c Column) IsNonCodeTableForeignKey() bool {
return c.IsForeignKey && strings.HasSuffix(c.Name, "_id")
}
// Table is a single SQLite table.
type Table struct {
TableName string `db:"name"`