Skip to content

dokilife/simplebank-demo

Repository files navigation

Doki

Setup local development

Install tools

  • Docker desktop

  • DBeaver

  • Golang

  • Migrate

    $ # Go 1.15 and below
    $ go get -tags 'postgres' -u github.com/golang-migrate/migrate/cmd/migrate
    $ # Go 1.16+
    $ go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
  • Sqlc

    $ # Go 1.17 and below
    go get github.com/sqlc-dev/sqlc/cmd/sqlc
    $ # Go 1.17+
    go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
  • Gomock

    $ # Go 1.16 below
    GO111MODULE=on go get github.com/golang/mock/[email protected]
    $ # Go 1.16+
    go install github.com/golang/mock/[email protected]
  • DB Docs

    npm install -g dbdocs
    dbdocs login
  • DBML CLI

    npm install -g @dbml/cli
    dbml2sql --version

Setup infrastructure

  • Start postgres container:

    make postgresup
  • Stop postgres container:

    make postgresdown
  • Create doki database:

    make createdb
  • Drop doki database:

    make dropdb
  • Run db migration up all versions:

    make migrateup
  • Run db migration up 1 version:

    make migrateup1
  • Run db migration down all versions:

    make migratedown
  • Run db migration down 1 version:

    make migratedown1

How to generate code

  • Generate schema SQL file with DBML:

    make db_schema
  • Generate SQL CRUD with sqlc:

    make sqlc
  • Generate DB mock with gomock:

    make mock
  • Create a new db migration:

    make new_migration name=<migration_name>

Documentation

  • Generate DB documentation:

    make db_docs
  • Access the DB documentation at this address. Password: secret

How to run

  • Run server:

    make server
  • Run test:

    make test

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published