pablop
April 21, 2021, 5:49pm
1
After a failed upgrade I cannot update to version 5.34.
I’m using the update script and after the service starts I get an error in the database migration.
Failed to apply database migrations
Dirty database version 1. Fix and force version.
Is there a way to force the migration to update the database schema?
pablop
April 21, 2021, 7:11pm
2
Solved.
As stated in
opened 03:17PM - 06 Jan 20 UTC
closed 03:20PM - 06 Jan 20 UTC
**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
```sql
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:
```go
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.
```
I dropped the table schema_migrations and could upgrade.
racso
(oscar rojas)
January 6, 2022, 5:35am
3
Hello. I am trying to update mattermost version 5.33.5 to version 5.37.6, I do all the steps indicated in the instructions, but I get this error:
Try to follow this forum where they say that you can delete the scheme_migrations table to clean the dirty database but it does not work, the table once given the DROP instruction is deleted but a few seconds later it reappears it is never deleted, so trying to start the mattermost service fails again with this error. I would like to know step by step what you gave him after the DROP table to follow you.
pablop
January 6, 2022, 3:06pm
4
How is that you drop the table and gets recreated?
My guess is that you don’t have sufficient permissions and you’re not deleting it at all.