Skip to content

Latest commit

 

History

History
64 lines (58 loc) · 1.54 KB

File metadata and controls

64 lines (58 loc) · 1.54 KB

Effective work with SQL in Go

Support Ukraine 🇺🇦

Testing

make env-up
make docker-go-version
make docker-pg-version
make migrate-up
make go-test
make env-down
make env-up
time make test
real	0m16.016s
user	0m0.168s
sys	0m0.079s

Examples

version: "2"
sql:
  - engine: "postgresql"
    queries: "./internal/storage/postgres/queries/"
    schema: "./internal/storage/postgres/migrations/"

    gen:
      go:
        package: "dbs"
        sql_package: "database/sql"
        out: "./internal/storage/postgres/dbs"
        emit_prepared_queries: true
-- name: CompanyNewAndGetID :one
INSERT INTO companies (alias, name, created_by, created_at)
VALUES (@alias, @name, @created_by, @created_at)
RETURNING id;

Development

make create-new-migration-file NAME=migration_name
mkdir -p ./internal/storage/postgres/queries/
make generate-sqlc

Tools