pub async fn migrated_db(models: ModelSet, migrations: &MigrationSet) -> DbExpand description
A Db over models whose tables migrations made, holding no rows: what the app’s
migrations add beside the models, such as a foreign key or a check constraint written by
hand, holds in the test too, where test_db pushes the models’ schema alone.
ⓘ
static MIGRATIONS: MigrationSet = toasty::embed_migrations!();
let db = migrated_db(app::models(), &MIGRATIONS).await;Migrations are SQL for one database, so the test runs where the app does: the database
TEST_DATABASE_URL names, else in-memory SQLite, fresh for each call. Migration SQL names
its tables in full, so on a shared database each call gets a namespace of its own instead of a
table prefix: a PostgreSQL schema its connections search, or a MySQL database. Neither is
dropped afterwards, as test_db’s tables are not.
§Panics
When the database refuses the connection, the namespace or a migration.