Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.11 KB

README.md

File metadata and controls

53 lines (40 loc) · 1.11 KB

Template for starting project

  • dockerfile and docker-compose
  • makfile
  • live reloading

used packages

  • viper
  • cobra
  • logrus
  • echo
  • gorm
  • golang-migrate

add command to cobra

cobra-cli add command_name

air package is used for live reloading

install:

go install github.com/cosmtrek/air@latest

change the setting in .air.toml file
run it :

air -c .air.toml

clean_on_exit option will delete the tmp directory on air exit, change it if you don't want to.

create migration

create migration

migrate create -ext sql -dir internall/infrastructure/migration/ -seq init_mg

-seq for sequential, UP file for moving db to new state, DOWN for reverting
apply migration

migrate -path internall/infrastructure/migration/ -database "postgresql://username:password@host:port/database_name?sslmode=disable" -verbose up

rollback

migrate -path internall/infrastructure/migration/ -database "postgresql://username:password@host:port/database_name?sslmode=disable" -verbose down