mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
43a9e2f1ca
sqlc is a tool that generates fully type-safe idiomatic code from SQL. The result is Go code can then used execute the queries in the database. The noraml flow looks like: - The developer write some sql that will update the schema in the database: new tables, indices, etc - The developer updates the set of queries that will use the new schema. - `sqlc` generates type-safe interfaces to those queries. - The developer can then write application code that calls the methods generated by sqlc. The tool configuration needs to live in the repo's root and its name is `sqlc.yaml`. LND will support out of the box sqlite and postgres. The sql code needs to be (almost) the same for both engines, so we cannot use custom functions like `ANY` in postgres. The SQLC config file needs to define what is the target engine, we will set postgres but the generated code can be executed by sqlite too. In some specific cases, we will `match and replace` some sql lines to be sure the table definitions are valid for the targeted engine.
11 lines
207 B
YAML
11 lines
207 B
YAML
version: "2"
|
|
sql:
|
|
- engine: "postgresql"
|
|
schema: "sqldb/sqlc/migrations"
|
|
queries: "sqldb/sqlc/queries"
|
|
gen:
|
|
go:
|
|
out: sqldb/sqlc
|
|
package: sqlc
|
|
emit_interface: true
|