Diesel migration problem: "Invalid migration directory"

I am also having issues with running diesel migration redo in order to drop my table. I am successfully able to create a table on postgres 14.x, but the redo command specifically complains that the directory is invalid, even though the only things in the directory are both the up/down.sql files.

>> <master>$ pwd
../myprojecti/migrations/2021-10-24-055129_create_user
>> <master>$ ls
down.sql  up.sql
>> <master>$ cat up.sql 
create table users (
  id uuid default uuid_generate_v4 (),
  username varchar not null,
  password varchar not null,
  email varchar not null,
  primary key (id)
)
>> <master>$ cat down.sql 
drop table users
>> <master>$ diesel migration redo
Failed with: Invalid migration directory, the directory's name should be <timestamp>_<name_of_migration>, and it should only contain up.sql and down.sql.
diesel = { version = "1.4.8", features = ["postgres"] }
rustc --version
rustc 1.56.0 (09c42c458 2021-10-18)
psql --version
psql (PostgreSQL) 14.0 (Ubuntu 14.0-1.pgdg20.04+1)

Have you tried running the command outside the migration directory? I get the same error when trying to do it inside one of them.

Yup, I feel like I'm missing something, not sure why its able to run a migration, but not a revert/redo.

>> <master>$ pwd
/home/me/Documents/my-project

>> <master>$ ls
Cargo.lock  Cargo.toml  diesel.toml  migrations  README.md  src  target

>> <master>$ diesel migration revert
Failed with: Invalid migration directory, the directory's name should be <timestamp>_<name_of_migration>, and it should only contain up.sql and down.sql.

>> <master>$ diesel migration redo
Failed with: Invalid migration directory, the directory's name should be <timestamp>_<name_of_migration>, and it should only contain up.sql and down.sql.

Wonder if it's better suited to open up an issue?

Ok, I found the issue? It's really odd but it seems like literally moving the generated migration out of the migrations folder and back into it somehow allowed the migration to be reverted?? Really, really, really weird.

All good :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.