45 lines
1.0 KiB
Cheetah
45 lines
1.0 KiB
Cheetah
{{/* Reusable template fragments */}}
|
|
|
|
{{/* Column definition fragment */}}
|
|
{{- define "column_definition" -}}
|
|
{{.Name}} {{.Type}}
|
|
{{- if .Default}} DEFAULT {{.Default}}{{end}}
|
|
{{- if .NotNull}} NOT NULL{{end}}
|
|
{{- end -}}
|
|
|
|
{{/* Comma-separated column list */}}
|
|
{{- define "column_list" -}}
|
|
{{- range $i, $col := . -}}
|
|
{{- if $i}}, {{end}}{{$col}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/* Qualified table name */}}
|
|
{{- define "qualified_table" -}}
|
|
{{.SchemaName}}.{{.TableName}}
|
|
{{- end -}}
|
|
|
|
{{/* Index method clause */}}
|
|
{{- define "index_method" -}}
|
|
{{- if .IndexType}}USING {{.IndexType}}{{end -}}
|
|
{{- end -}}
|
|
|
|
{{/* Uniqueness keyword */}}
|
|
{{- define "unique_keyword" -}}
|
|
{{- if .Unique}}UNIQUE {{end -}}
|
|
{{- end -}}
|
|
|
|
{{/* Referential action clauses */}}
|
|
{{- define "referential_actions" -}}
|
|
{{- if .OnDelete}}
|
|
ON DELETE {{.OnDelete}}
|
|
{{- end}}
|
|
{{- if .OnUpdate}}
|
|
ON UPDATE {{.OnUpdate}}
|
|
{{- end}}
|
|
{{- end -}}
|
|
|
|
{{/* Comment statement */}}
|
|
{{- define "comment_on" -}}
|
|
COMMENT ON {{.ObjectType}} {{.ObjectName}} IS {{quote .Comment}};
|
|
{{- end -}} |