diff --git a/src/core/db/postgres_db.rs b/src/core/db/postgres_db.rs index 59ad88b4..52ee8bb5 100644 --- a/src/core/db/postgres_db.rs +++ b/src/core/db/postgres_db.rs @@ -1071,6 +1071,20 @@ impl PostgresDb { // ── Schema Migrations (tracking table, used by health check) ── sqlx::query("CREATE TABLE IF NOT EXISTS schema_migrations (id SERIAL PRIMARY KEY, filename TEXT NOT NULL UNIQUE, checksum TEXT NOT NULL, applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), duration_ms INTEGER DEFAULT 0)").execute(pool).await?; + // ── Check if schema.sql was applied (skip migrations if so) ── + let applied_count: i64 = sqlx::query_scalar( + "SELECT COUNT(*) FROM schema_migrations" + ) + .fetch_one(pool) + .await + .unwrap_or(0); + + if applied_count >= 42 { + tracing::info!("Schema already fully applied ({} migrations), skipping migration files", applied_count); + tracing::info!("This indicates schema.sql was used for initial setup"); + return Ok(()); + } + // ── Videos ── // ───────────────────────────────────────────────────────────────────────────── // DISABLED: Hardcoded DDL (moved to migrations/*.sql)