Skip to main content

dangerously_recreate

Function dangerously_recreate 

Source
pub async fn dangerously_recreate(
    pool: &PgPool,
    migrator: &Migrator,
) -> Result<(), MigrateError>
Expand description

Drop every table and enum type in public, then migrate from nothing. This gives each test an empty schema, whatever tables it touched.

This destroys all data. It exists for tests, and a service must never reach it outside the test environment.

It drops tables and types by name rather than dropping the schema, because DROP SCHEMA public CASCADE would also remove the extensions a database was prepared with, such as citext. Functions are left in place, so a migration that creates one should use CREATE OR REPLACE.

ยงErrors

Fails on a database error, or a name quote_identifier refuses.