-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlc.yaml
More file actions
43 lines (43 loc) · 1.96 KB
/
Copy pathsqlc.yaml
File metadata and controls
43 lines (43 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# sqlc configuration for the PostgreSQL todo adapter.
#
# The schema is read directly from the goose migrations (sqlc understands goose
# annotations natively, so there is no separate schema.sql to drift). Generated
# code lands in internal/todo/postgres/sqlc and is committed; the sqlc-check
# moon task guards it against drift. The schema stays under the shared
# internal/adapter/postgres (database-level concern), while the generated code
# and queries live with the todo domain.
version: "2"
sql:
- engine: postgresql
schema: internal/adapter/postgres/migrations
queries: internal/todo/postgres/queries
gen:
go:
package: sqlc
out: internal/todo/postgres/sqlc
sql_package: pgx/v5
emit_pointers_for_null_types: true
emit_interface: true
# Only emit structs for tables/enums referenced by a todo query. The
# api_keys table lives in the shared migrations dir (read as the schema)
# but is queried by the apikey adapter's hand-written pgx, not sqlc, so
# this keeps the todo sqlc package free of an unused ApiKey model and
# leaves it untouched whether the api_keys migration is present or not.
omit_unused_structs: true
overrides:
# ID column maps to the same uuid.UUID the rest of the codebase uses;
# the adapter converts to/from the domain's string at the boundary.
- db_type: uuid
go_type: github.com/google/uuid.UUID
# Map timestamptz to the standard time.Time rather than the pgx
# pgtype wrapper so the generated rows mirror the domain entity. The
# non-nullable created_at becomes time.Time; the nullable
# completed_at becomes *time.Time (matching todo.Todo.CompletedAt).
- db_type: timestamptz
nullable: false
go_type: time.Time
- db_type: timestamptz
nullable: true
go_type:
type: time.Time
pointer: true