Skip to content

migrate! silently ignores *.sql files with no prefix #4362

Description

@m7md-rs

I have found these related issues/pull requests

I was unable to find any related issues

Description

If a migration file has a non-numeric prefix (e.g., a_schema.sql), SQLx produces an error. However, if there is no prefix at all (e.g., schema.sql), no error is produced, and migrate! silently ignores the file. I believe this should either: produce an error (or warning) message like above, for any *.sql file that doesn't follow the required format; or, begin supporting no-prefix migrations.

Reproduction steps

  1. Write a function to create the SQLite database and run migrations, e.g.
let connect_options = SqliteConnectOptions::new()
    .filename("foo.db")
    .create_if_missing(true);

let pool = SqlitePoolOptions::new()
    .connect_with(connect_options)
    .await?;

dbg!(sqlx::migrate!("./migrations/")).run(&pool).await?;
  1. Create a no-prefix sql file, e.g. ./migrations/schema.sql. Make it create any sort of table or whatever
  2. Run
  3. The database file, foo.db, will be created and initialized, but it will not contain the new table defined in schema.sql. The evaluation of migrate! as shown by dbg! will have an empty migrations field. Additionally, running something like .tables in sqlite3 will only show the _sqlx_migrations table. In other words, the schema.sql file was ignored, silently.

SQLx version

0.9.0

Enabled SQLx features

runtime-tokio, sqlite

Database server and version

SQLite

Operating system

Linux mint 6.8.0-136-generic

Rust version

rustc 1.97.1(8bab26f4f 2026-07-14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions