2.2 KiB
2.2 KiB
Deployment Fix Plan - Kites
Status
- Current State:
kites.runfoo.runis down (521 Error). - Recent Error:
Can't find meta/_journal.json fileduring migration startup. - Previous Error:
relation "account" already exists(Fixed by manual SQL edit, but likely caused the journal issue).
Goal
Restore service availability by fixing the database migration process and ensuring the application container starts successfully.
Analysis
The application uses Drizzle ORM for database management. The startup sequence runs a migration script (src/db/migrate.ts).
- The initial crash was due to existing tables conflicting with the migration script trying to create them again.
- We manually edited the SQL to be idempotent (
IF NOT EXISTS). - The new error suggests the Drizzle migration metadata (
_journal.json) is missing or corrupt in the runtime environment. This file is required bydrizzle-kitto track migration history.
Steps
-
Verify Local State:
- Check contents of
apps/web/drizzlefolder. - Confirm if
meta/_journal.jsonexists.
- Check contents of
-
Fix Migration Artifacts:
- Run
drizzle-kit generate(orpush) locally to ensure the SQL and Journal are consistent and properly generated by the tool, rather than manually edited. - If we want to maintain the
IF NOT EXISTSsafety, we might need to check if Drizzle supports this natively or if we need to modify the generated SQL and ensure the snapshots utilize Custom migrations if needed. - Alternative: Since the DB already exists and has tables, we can introspect (pull) or just ensure the migration table tracks it as "done" if it's already done. But
IF NOT EXISTSis the safest path for a "dumb" apply. - Action: Run
drizzle-kit generateto repair_journal.json.
- Run
-
Check Build Configuration:
- Inspect
Dockerfile(both in root andapps/web) to ensure thedrizzlefolder (includingmeta) is copied to the final image.
- Inspect
-
Deploy Fix:
- Commit the repaired migration files.
- Push to
github. - Pull on
nexus-vector. - Rebuild/Restart the container.
Verification
- Monitor logs of
kites-kites-1onnexus-vectorto confirm successful migration and startup. - Visit
https://kites.runfoo.run.