83 lines
2.3 KiB
TOML
83 lines
2.3 KiB
TOML
DBType = "postgres"
|
|
|
|
# ConnStr is the connection string for the database where the schema is
|
|
# generated from
|
|
ConnStr = "dbname=postgres host=127.0.0.1 sslmode=disable user=postgres password=postgres"
|
|
|
|
Schemas = ["public"]
|
|
|
|
ExcludeTables = ["schema_migrations"]
|
|
|
|
# Run this command after generation, to lint the generated files
|
|
PostRun = ["goimports", "-w", "$GNORMFILE"]
|
|
|
|
# PascalCase should be used for our go database
|
|
NameConversion = "{{pascal .}}"
|
|
|
|
# Generate in the current directory. If this is changed, the RootPkg
|
|
# below should match the folder name.
|
|
OutputDir = "."
|
|
|
|
[Params]
|
|
# RootPkg is the package declaration for the output dir. It should match the
|
|
# directory name above.
|
|
RootPkg = "postgres"
|
|
|
|
# RootImport is the import path for the output directory.
|
|
RootImport = "git.klink.asia/paul/kregistry/database/postgres"
|
|
|
|
[SchemaPaths]
|
|
"fields.go" = "_templates/fields.gotmpl"
|
|
"db.go" = "_templates/db.gotmpl"
|
|
|
|
[TablePaths]
|
|
"{{toLower .Table}}/{{toLower .Table}}.go" = "_templates/table.gotmpl"
|
|
|
|
[EnumPaths]
|
|
"enum/{{toLower .Enum}}.go" = "_templates/enum.gotmpl"
|
|
|
|
[TypeMap]
|
|
"timestamp with time zone" = "time.Time"
|
|
"timestamp without time zone" = "time.Time"
|
|
"timestamptz" = "time.Time"
|
|
"timestamp" = "time.Time"
|
|
"varchar" = "string"
|
|
"text" = "string"
|
|
"citext" = "string"
|
|
"boolean" = "bool"
|
|
"uuid" = "uuid.UUID" # from "github.com/satori/go.uuid"
|
|
"character varying" = "string"
|
|
"character" = "string"
|
|
"bigserial" = "int64"
|
|
"bigint" = "int64"
|
|
"integer" = "int"
|
|
"int4" = "int32"
|
|
"numeric" = "float64"
|
|
"real" = "float64"
|
|
"hstore" = "hstore.Hstore" # from "github.com/lib/pq/hstore"
|
|
"jsonb" = "postgres.Jsonb" # package name here has to be kept in sync with RootPkg.
|
|
"bytea" = "postgres.Bytes"
|
|
|
|
# needs to be kept in sync with the enum template's package name
|
|
"rank" = "enum.Rank"
|
|
|
|
|
|
[NullableTypeMap]
|
|
"timestamp with time zone" = "pq.NullTime"
|
|
"timestamptz" = "pq.NullTime"
|
|
"timestamp" = "pq.NullTime"
|
|
"text" = "sql.NullString"
|
|
"citext" = "sql.NullString"
|
|
"varchar" = "sql.NullString"
|
|
"public.citext" = "sql.NullString"
|
|
"boolean" = "sql.NullBool"
|
|
"uuid" = "uuid.NullUUID"
|
|
"character varying" = "sql.NullString"
|
|
"character" = "sql.NullString"
|
|
"integer" = "sql.NullInt64"
|
|
"bigint" = "sql.NullInt64"
|
|
"numeric" = "sql.NullFloat64"
|
|
"real" = "sql.NullFloat64"
|
|
"hstore" = "hstore.Hstore"
|
|
"jsonb" = "postgres.Jsonb" # package name here has to be kept in sync with RootPkg.
|
|
"bytea" = "postgres.NullBytes"
|