Answer the question
In order to leave comments, you need to log in
Why are migrations not running?
Hello!
I want to make the first migration for my database using migrate. But it gives the following error:
What could be the problem?
PS
Here is the running docker:
Here is the code when migrating up:
CREATE TABLE users
(
id serial not null unique,
name varchar(255) not null,
username varchar(255) not null unique,
);
Answer the question
In order to leave comments, you need to log in
This usually means that a migration was previously attempted and an error occurred during the migration.
For example, you have only one migration (version 1) with the creation of the `users` table as in your case.
You run the up command, and there is an error in the migrations file.
In this case, the `users` table was not created in the database, but the `migrate` command has already created the schema_migrations table.
And not just created, but also wrote down there that your database corresponds to version 1 and set the `dirty` flag.
SELECT * FROM schema_migrations;
+---------+-------+
| version | dirty |
+---------+-------+
| 1 | 1 |
+---------+-------+
1 row in set (0.00 sec)
migrate -path $PATH_TO_YOUR_MIGRATIONS -database $YOUR_DATABASE_URL force $VERSION
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question