DEV Community

Discussion on: How to write & run database migration in Golang

Collapse
 
acetorscode profile image
Apoorv Mishra

Getting this error while migratedown

"Dirty database version -1. Fix and force version."

can anyone help with a solution! it will be a great help if you can.

Collapse
 
mquanit profile image
Mohammad Quanit

Hi Apoorv, try this cmd first

migrate -path db/migration -database "postgresql://root:secret@localhost:5432/simple_bank?sslmode=disable" force 1

and then run makefile cmd

make migrateup

it should solve this issue. Here's the docs for it
github.com/golang-migrate/migrate/...