kites/fix_deployment_plan.md

2.2 KiB

Deployment Fix Plan - Kites

Status

  • Current State: kites.runfoo.run is down (521 Error).
  • Recent Error: Can't find meta/_journal.json file during 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).

  1. The initial crash was due to existing tables conflicting with the migration script trying to create them again.
  2. We manually edited the SQL to be idempotent (IF NOT EXISTS).
  3. The new error suggests the Drizzle migration metadata (_journal.json) is missing or corrupt in the runtime environment. This file is required by drizzle-kit to track migration history.

Steps

  1. Verify Local State:

    • Check contents of apps/web/drizzle folder.
    • Confirm if meta/_journal.json exists.
  2. Fix Migration Artifacts:

    • Run drizzle-kit generate (or push) 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 EXISTS safety, 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 EXISTS is the safest path for a "dumb" apply.
    • Action: Run drizzle-kit generate to repair _journal.json.
  3. Check Build Configuration:

    • Inspect Dockerfile (both in root and apps/web) to ensure the drizzle folder (including meta) is copied to the final image.
  4. Deploy Fix:

    • Commit the repaired migration files.
    • Push to github.
    • Pull on nexus-vector.
    • Rebuild/Restart the container.

Verification

  • Monitor logs of kites-kites-1 on nexus-vector to confirm successful migration and startup.
  • Visit https://kites.runfoo.run.