- bun: scanonly+generated for GENERATED columns; scanonly+identity for ALWAYS identity (PK gets identity only) - gorm: <-:false+generated / identity, same primary key rule - dbml: write GENERATED/IDENTITY column notes and read them back into the model - pgsql: emit generation/identity clauses in migration create-table and add-column, no DEFAULT - readmes updated
10 lines
460 B
Cheetah
10 lines
460 B
Cheetah
CREATE TABLE IF NOT EXISTS {{qual_table .SchemaName .TableName}} (
|
|
{{- range $i, $col := .Columns}}
|
|
{{- if $i}},{{end}}
|
|
{{quote_ident $col.Name}} {{$col.Type}}
|
|
{{- if $col.Generated}} GENERATED ALWAYS AS ({{$col.Generated}}) STORED{{end}}
|
|
{{- if $col.Identity}} GENERATED {{$col.Identity}} AS IDENTITY{{end}}
|
|
{{- if and $col.Default (not $col.Generated) (not $col.Identity)}} DEFAULT {{$col.Default}}{{end}}
|
|
{{- if $col.NotNull}} NOT NULL{{end}}
|
|
{{- end}}
|
|
); |