Skip to content

rfanazhari/fun-with-gin

Repository files navigation

Fun with Gin-Gonic Golang

Prerequisite

This project has the following prerequisites:

Installation

  1. sync go modules
    go mod tidy 

Migration Database

  1. download and install golang-migrate -> https://github.com/golang-migrate/migrate/tree/master/cmd/migrate
  2. migrate up
    migrate -source "file://migrations/pgsql" -database "postgres://username:pwd@localhost:5432/your_db?sslmode=disable&search_path=apps" up 
  3. create new migration (if needed)
    migrate create -ext sql -dir migrations/pgsql create_my_table

Run Apps

  1. apps -> execute file
    sh main.sh
  2. migration & seeder -> execute file
    sh migration.sh
  3. using docker-compose
    docker-compose up -d
  4. if using docker the migration should execute inside the container
    docker ps
    docker exec -it CONTAINER-ID bash
    cd cmd/migration
    go run main.go