Skip to content

Connecting golang with PostgreSQL, database migration using flags and Crud Rest Api

Notifications You must be signed in to change notification settings

husnainkhurshiid/Postgres-Golang-Migration-Rest_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postgres-Golang-Connection

  • Connection String

    postgres://<username>:<password>@localhost/<database_name>?sslmode=disable
  • Run Migration

    • Up

        go run main.go --migration up
      
    • Down

        go run main.go --migration down
      
  • Error Handling

    If you're getting the bellow error

    Error parsing migration (table_name.sql): ERROR: no Up/Down annotations found, so no statements were executed.
    

    In the migration file Set tags as Up and Down instead of up down

    • -- +migrate UP
    • -- +migrate Down

About

Connecting golang with PostgreSQL, database migration using flags and Crud Rest Api

Topics

Resources

Stars

Watchers

Forks

Languages