chore(dev): setup sqlc and atlas
This commit is contained in:
parent
1ebb4936ea
commit
2efa42651f
6 changed files with 58 additions and 1 deletions
|
@ -1,2 +1,3 @@
|
|||
# short
|
||||
|
||||
URL Shortener written in Go
|
||||
|
|
7
atlas.hcl
Normal file
7
atlas.hcl
Normal file
|
@ -0,0 +1,7 @@
|
|||
env "local" {
|
||||
src = "file://sql/schema.sql"
|
||||
url = "postgres://short:short@localhost:5432/short?sslmode=disable"
|
||||
migration {
|
||||
dir = "file://sql/migrations"
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
version: '3.1'
|
||||
version: "3.1"
|
||||
|
||||
services:
|
||||
db:
|
||||
|
|
12
flake.nix
12
flake.nix
|
@ -21,6 +21,7 @@
|
|||
alejandra.enable = true;
|
||||
deadnix.enable = true;
|
||||
gofumpt.enable = true;
|
||||
prettier.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -29,6 +30,17 @@
|
|||
# Go tools
|
||||
go
|
||||
gopls
|
||||
|
||||
# Database
|
||||
atlas
|
||||
sqlc
|
||||
postgresql_16
|
||||
|
||||
# Lint
|
||||
golangci-lint
|
||||
|
||||
# Tools
|
||||
just
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
23
justfile
Normal file
23
justfile
Normal file
|
@ -0,0 +1,23 @@
|
|||
alias b := build
|
||||
alias r := run
|
||||
alias l := lint
|
||||
|
||||
build:
|
||||
go build .
|
||||
|
||||
run:
|
||||
go run .
|
||||
|
||||
lint:
|
||||
golangci-lint run
|
||||
|
||||
sqlc:
|
||||
sqlc generate
|
||||
sqlc vet
|
||||
|
||||
gen-migration NAME:
|
||||
atlas migrate diff {{NAME}} --env local
|
||||
atlas migrate apply --env local
|
||||
|
||||
migrate:
|
||||
atlas migrate apply --env local
|
14
sqlc.yaml
Normal file
14
sqlc.yaml
Normal file
|
@ -0,0 +1,14 @@
|
|||
version: "2"
|
||||
sql:
|
||||
- engine: "postgresql"
|
||||
queries: "sql/query.sql"
|
||||
schema: "sql/schema.sql"
|
||||
database:
|
||||
uri: postgres://short:short@localhost:5432/short
|
||||
gen:
|
||||
go:
|
||||
package: "db"
|
||||
out: "internal/db"
|
||||
sql_package: "pgx/v5"
|
||||
rules:
|
||||
- sqlc/db-prepare
|
Loading…
Reference in a new issue