-
Notifications
You must be signed in to change notification settings - Fork 888
docs: Add managed dbs to CI/CD and vet guides #2896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d303a07
docs: Add managed dbs to CI/CD and vet guides
kyleconroy 8af7fdb
Update docs/howto/ci-cd.md
kyleconroy fd4748b
Update docs/howto/ci-cd.md
kyleconroy 9942bae
Update docs/howto/ci-cd.md
kyleconroy 41187f5
Update docs/howto/vet.md
kyleconroy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -4,15 +4,16 @@ | |||||||||
|
||||||||||
`sqlc vet` runs queries through a set of lint rules. | ||||||||||
|
||||||||||
Rules are defined in the `sqlc` [configuration](../reference/config) file. They consist | ||||||||||
of a name, message, and a [Common Expression Language (CEL)](https://github.com/google/cel-spec) | ||||||||||
expression. Expressions are evaluated using [cel-go](https://github.com/google/cel-go). | ||||||||||
If an expression evaluates to `true`, `sqlc vet` will report an error using the given message. | ||||||||||
Rules are defined in the `sqlc` [configuration](../reference/config) file. They | ||||||||||
consist of a name, message, and a [Common Expression Language | ||||||||||
(CEL)](https://github.com/google/cel-spec) expression. Expressions are evaluated | ||||||||||
using [cel-go](https://github.com/google/cel-go). If an expression evaluates to | ||||||||||
`true`, `sqlc vet` will report an error using the given message. | ||||||||||
|
||||||||||
## Defining lint rules | ||||||||||
|
||||||||||
Each lint rule's CEL expression has access to information from your sqlc configuration and queries | ||||||||||
via variables defined in the following proto messages. | ||||||||||
Each lint rule's CEL expression has access to information from your sqlc | ||||||||||
configuration and queries via variables defined in the following proto messages. | ||||||||||
|
||||||||||
```proto | ||||||||||
message Config | ||||||||||
|
@@ -190,13 +191,27 @@ sql: | |||||||||
- sqlc/db-prepare | ||||||||||
``` | ||||||||||
|
||||||||||
Databases configured with a `uri` must have an up-to-date schema, and `sqlc` does not apply schema migrations your database. You can configure [managed databases](managed-databases.md) instead to have `sqlc` create and migrate databases automatically. | ||||||||||
|
||||||||||
```yaml | ||||||||||
version: 2 | ||||||||||
sql: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
- schema: "query.sql" | ||||||||||
queries: "query.sql" | ||||||||||
engine: "postgresql" | ||||||||||
gen: | ||||||||||
go: | ||||||||||
package: "authors" | ||||||||||
out: "db" | ||||||||||
database: | ||||||||||
managed: true | ||||||||||
rules: | ||||||||||
- sqlc/db-prepare | ||||||||||
``` | ||||||||||
|
||||||||||
To see this in action, check out the [authors | ||||||||||
example](https://github.com/sqlc-dev/sqlc/blob/main/examples/authors/sqlc.yaml). | ||||||||||
|
||||||||||
Please note that `sqlc` does not manage or migrate your database. Use your | ||||||||||
migration tool of choice to create the necessary database tables and objects | ||||||||||
before running `sqlc vet` with the `sqlc/db-prepare` rule. | ||||||||||
|
||||||||||
## Running lint rules | ||||||||||
|
||||||||||
When you add the name of a defined rule to the rules list | ||||||||||
|
@@ -238,4 +253,4 @@ For any query, you can tell `sqlc vet` not to evaluate lint rules using the | |||||||||
/* @sqlc-vet-disable */ | ||||||||||
SELECT * FROM authors | ||||||||||
WHERE id = ? LIMIT 1; | ||||||||||
``` | ||||||||||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need the
env
here forSQLC_AUTH_TOKEN
right?