squash database migrations
This commit is contained in:
@@ -37,6 +37,7 @@ use tower::util::ServiceExt;
|
||||
use uuid::Uuid;
|
||||
|
||||
const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
|
||||
const RESET_SCHEMA_SQL: &str = include_str!("../../migrations/202510300000_initial_schema/down.sql");
|
||||
|
||||
static DB_LOCK: Lazy<Mutex<()>> = Lazy::new(|| Mutex::new(()));
|
||||
|
||||
@@ -697,6 +698,8 @@ async fn prepare_database(pool: &PgPool) -> Result<()> {
|
||||
let mut conn = pool
|
||||
.get()
|
||||
.map_err(|err| anyhow!("failed to acquire connection: {err}"))?;
|
||||
let _ = conn.batch_execute(RESET_SCHEMA_SQL);
|
||||
let _ = conn.batch_execute("DROP TABLE IF EXISTS __diesel_schema_migrations;");
|
||||
conn.run_pending_migrations(MIGRATIONS)
|
||||
.map_err(|err| anyhow!("failed to run migrations: {err}"))?;
|
||||
truncate_all(&mut conn)?;
|
||||
@@ -721,6 +724,8 @@ fn truncate_all(conn: &mut PgConnection) -> Result<()> {
|
||||
refresh_tokens, \
|
||||
tags, \
|
||||
webdav_tokens, \
|
||||
webauthn_challenges, \
|
||||
user_passkeys, \
|
||||
user_memberships, \
|
||||
users, \
|
||||
tenants \
|
||||
|
||||
Reference in New Issue
Block a user