generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
sqlc.yaml
198 lines (198 loc) · 7.88 KB
/
sqlc.yaml
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
version: "2"
sql:
- &daldir
engine: "postgresql"
queries:
- backend/controller/dal/internal/sql/queries.sql
- backend/controller/dal/internal/sql/async_queries.sql
- backend/controller/pubsub/internal/sql/queries.sql
# Some of the timeline entries happen within a controller transaction, so we need to include them here
- backend/controller/timeline/internal/sql/deployment_queries.sql
schema: "backend/controller/sql/schema"
database:
uri: postgres://localhost:15432/ftl?sslmode=disable&user=postgres&password=secret
gen:
go: &gengo
package: "sql"
omit_unused_structs: true
out: "backend/controller/dal/internal/sql"
emit_interface: true
query_parameter_limit: 3
overrides:
- db_type: "uuid"
go_type: "github.com/google/uuid.UUID"
- db_type: "uuid"
nullable: true
go_type:
type: "optional.Option[uuid.UUID]"
- db_type: "timestamptz"
go_type: "time.Time"
- db_type: "pg_catalog.interval"
go_type: "github.com/TBD54566975/ftl/backend/controller/sql/sqltypes.Duration"
- db_type: "pg_catalog.interval"
nullable: true
go_type:
type: "optional.Option[sqltypes.Duration]"
- db_type: "module_schema_pb"
go_type: "*github.com/TBD54566975/ftl/internal/schema.Module"
- db_type: "timestamptz"
nullable: true
go_type: "github.com/TBD54566975/ftl/backend/controller/sql/sqltypes.OptionalTime"
- db_type: "pg_catalog.varchar"
nullable: true
go_type: "github.com/alecthomas/types/optional.Option[string]"
- db_type: "runner_key"
go_type: "github.com/TBD54566975/ftl/internal/model.RunnerKey"
- db_type: "runner_key"
nullable: true
go_type:
type: "optional.Option[model.RunnerKey]"
- db_type: "schema_ref"
go_type: "github.com/TBD54566975/ftl/internal/schema.RefKey"
- db_type: "schema_ref"
nullable: true
go_type:
type: "optional.Option[schema.RefKey]"
- db_type: "schema_type"
go_type: "github.com/TBD54566975/ftl/backend/controller/sql/sqltypes.Type"
- db_type: "schema_type"
nullable: true
go_type:
type: "optional.Option[Type]"
- db_type: "encrypted_identity"
go_type: "github.com/TBD54566975/ftl/backend/controller/encryption/api.EncryptedIdentityColumn"
- db_type: "encrypted_async"
go_type: "github.com/TBD54566975/ftl/backend/controller/encryption/api.EncryptedAsyncColumn"
- db_type: "encrypted_async"
nullable: true
go_type: "github.com/TBD54566975/ftl/backend/controller/encryption/api.OptionalEncryptedAsyncColumn"
- db_type: "encrypted_timeline"
go_type: "github.com/TBD54566975/ftl/backend/controller/encryption/api.EncryptedTimelineColumn"
- db_type: "encrypted_timeline"
nullable: true
go_type: "github.com/TBD54566975/ftl/backend/controller/encryption/api.OptionalEncryptedTimelineColumn"
- db_type: "lease_key"
go_type: "github.com/TBD54566975/ftl/backend/controller/leases.Key"
- db_type: "lease_key"
nullable: true
go_type:
type: "optional.Option[leases.Key]"
- db_type: "deployment_key"
go_type: "github.com/TBD54566975/ftl/internal/model.DeploymentKey"
- db_type: "deployment_key"
nullable: true
go_type:
type: "optional.Option[model.DeploymentKey]"
- db_type: "controller_key"
go_type: "github.com/TBD54566975/ftl/internal/model.ControllerKey"
- db_type: "request_key"
go_type: "github.com/TBD54566975/ftl/internal/model.RequestKey"
- db_type: "request_key"
nullable: true
go_type:
type: "optional.Option[model.RequestKey]"
- db_type: "topic_key"
go_type: "github.com/TBD54566975/ftl/internal/model.TopicKey"
- db_type: "topic_key"
nullable: true
go_type:
type: "optional.Option[model.TopicKey]"
- db_type: "subscription_key"
go_type: "github.com/TBD54566975/ftl/internal/model.SubscriptionKey"
- db_type: "subscription_key"
nullable: true
go_type:
type: "optional.Option[model.SubscriptionKey]"
- db_type: "subscriber_key"
go_type: "github.com/TBD54566975/ftl/internal/model.SubscriberKey"
- db_type: "subscriber_key"
nullable: true
go_type:
type: "optional.Option[model.SubscriberKey]"
- db_type: "topic_event_key"
go_type: "github.com/TBD54566975/ftl/internal/model.TopicEventKey"
- db_type: "topic_event_key"
nullable: true
go_type:
import: github.com/alecthomas/types/optional
type: "Option[model.TopicEventKey]"
- db_type: "text"
go_type: "string"
- db_type: "text"
nullable: true
go_type: "github.com/alecthomas/types/optional.Option[string]"
- db_type: "bytes"
nullable: true
go_type: "github.com/alecthomas/types/optional.Option[[]byte]"
- db_type: "pg_catalog.int8"
nullable: true
go_type: "github.com/alecthomas/types/optional.Option[int64]"
- db_type: "bigint"
nullable: true
go_type: "github.com/alecthomas/types/optional.Option[int64]"
- db_type: "int"
nullable: true
go_type: "github.com/alecthomas/types/optional.Option[int32]"
- db_type: "bool"
nullable: true
go_type: "github.com/alecthomas/types/optional.Option[bool]"
- column: "controller.key"
go_type: "github.com/TBD54566975/ftl/internal/model.ControllerKey"
- column: "deployments.name"
go_type: "github.com/TBD54566975/ftl/internal/model.DeploymentKey"
- column: "events.payload"
go_type: "encoding/json.RawMessage"
rules:
- sqlc/db-prepare
# - postgresql-query-too-costly
# - postgresql-no-seq-scan
- <<: *daldir
queries: "internal/configuration/dal/internal/sql/queries.sql"
gen:
go:
<<: *gengo
out: "internal/configuration/dal/internal/sql"
- <<: *daldir
queries:
- backend/controller/leases/dbleaser/internal/sql/queries.sql
gen:
go:
<<: *gengo
out: "backend/controller/leases/dbleaser/internal/sql"
- <<: *daldir
queries:
- backend/controller/identity/internal/sql/queries.sql
gen:
go:
<<: *gengo
out: "backend/controller/identity/internal/sql"
- <<: *daldir
queries:
- backend/controller/encryption/internal/sql/queries.sql
gen:
go:
<<: *gengo
out: "backend/controller/encryption/internal/sql"
- <<: *daldir
queries:
- backend/controller/timeline/internal/sql/queries.sql
- backend/controller/timeline/internal/sql/deployment_queries.sql
gen:
go:
<<: *gengo
out: "backend/controller/timeline/internal/sql"
- <<: *daldir
queries:
- backend/controller/pubsub/internal/sql/queries.sql
- backend/controller/dal/internal/sql/async_queries.sql
gen:
go:
<<: *gengo
out: "backend/controller/pubsub/internal/sql"
rules:
- name: postgresql-query-too-costly
message: "Query cost estimate is too high"
rule: "postgresql.explain.plan.total_cost > 500.0"
- name: postgresql-no-seq-scan
message: "Query plan results in a sequential scan"
rule: "postgresql.explain.plan.node_type == 'Seq Scan'"