Describe the Bug
Migrations do not run due to the following error message
Dirty database version 1. Fix and force version.
Steps to Reproduce
I have created my up and down sql migration scripts that begin something like this
CREATE database mydb;
USE mydb;
CREATE TABLE IF NOT EXISTS "mytable" (
"id" int PRIMARY KEY,
"day" date NOT NULL,
"somefield" varchar NOT NULL
);
Here is the function that runs the migrations:
func RunMigrations() {
m, err := migrate.New(
"file://db/migrations",
"postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable")
if err != nil {
log.Fatal(err)
}
if err := m.Up(); err != nil {
log.Fatal(err)
}
}
Expected Behavior
Migrations should have been run with success
Migrate Version
4.7.1
Loaded Source Drivers
file
Loaded Database Drivers
postgres
Go Version
go version go1.13.1 darwin/amd64
Stacktrace
Dirty database version 1. Fix and force version.
Hey, did you fix this issue? Having the same problem
@nickmurr try drop table schema_migrations; and the table will be recreated on next "first time" up
@nickmurr try
drop table schema_migrations;and the table will be recreated on next "first time"up
that was the best workaround (and perhaps solution) across all answers throughout the web
Most helpful comment
@nickmurr try
drop table schema_migrations;and the table will be recreated on next "first time"up