ekopras18 / go-learn-crud-mysql

CRUD blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

To Do List

  • Search Data
  • Auth JWT
  • Middleware
  • Dockerisation
  • Darkmode UI

Learn Crud Golang

#golang-migration

firstime you need instal package golang-migrate

  brew install golang-migrate

#create migration

  • original :
  migrate create -ext sql  -dir <path> -seq <migration_name>

example :

  migrate create -ext sql  -dir config/migrations -seq tags
  • modif on your mac
  1. nano ~/.zshrc
  2. add alias
  alias go-migrate="migrate create -ext sql"
  1. and then create migration like this :
  go-migrate -dir <path> -seq <migration_name>

example :

  go-migrate -dir config/migrations -seq tags

how to UP

  migrate -path <path> -database ‘<connection_string>’ -verbose up

example :

  migrate -path config/migrations/ -database 'mysql://user:password@/database_name' -verbose up

how to DOWN

  migrate -path <path> -database ‘<connection_string>’ -verbose down

example :

  migrate -path config/migrations/ -database 'mysql://user:password@/database_name’ -verbose down

About

CRUD blog


Languages

Language:HTML 52.4%Language:Go 47.6%