RFC: how should sqlx-cli handle migrations in dependencies? #3761
Labels
cli
Concerns `sqlx-cli`
enhancement
New feature or request
migrations
Proposals or bugs involving migrations
proposal
A question that I ran into while implementing the multi-tenant example in #3383 is how to make it more convenient to run migrations from multiple crates at once.
sqlx-cli
could gain a--recursive
flag that checkssubdirectories for
sqlx.toml
files, but that would only work for crates within the directory tree.For dependencies from crates.io that need to run migrations (e.g.
tower-sessions-sqlx-store
), we would probably need to check dependencies through Cargo.I'm imagining something like
cargo sqlx db setup --deps
which scans dependencies for migrations folders, but we don't want to just assume that amigrations/
folder existing means SQLx should run the scripts within; they could be using a different tool. Scanning dependencies' sources forsqlx.toml
files would also likely be pretty inefficient.For best results this should probably be explicitly opt-in per crate. The dependent crate could have something like this in its
sqlx.toml
:This would require running as
cargo sqlx
so we can usecargo metadata
to look up the dependencies.The text was updated successfully, but these errors were encountered: