ernitingarg / golang-postgres-sqlc-bank-backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overview

Prerequisites installation

  • Dbeaver Universal database GUI tool: Download
  • Make:
    • Download or choco install make
    • make --version
  • golang-migrate:
  • sqlc (if not to be used as docker)
  • gomock:
    • [Install] go install go.uber.org/mock/mockgen@latest
    • mockgen --version

Run docker containers locally

To run container, please follow below steps:

make start
  • To stop docker containers
make stop
  • To remove docker containers
make remove
  • To see containers logs
make logs_db
make logs_sqlc
  • To connect to Postgres database manually
 docker exec -it postgres bash
 psql -U admin -d postgresdb
  • To see all tables in database
\dt;

Migration

  • To create migration
make migrate_create
make migrate_create NAME=init
  • To apply migration
make migrate_up
make migrate_down
  • Code generation
Code from db/queries is automatically generated using sqlc docker container which has command `generate`.

Server

  • To start server
make server

Test

  • To generate mock files
make mock
  • To run unit tests
make test

About


Languages

Language:Go 98.6%Language:Makefile 1.4%