Skip to content

Implement Zero-Downtime Schema Migrations (v0.1 to v0.2) #29

Description

@SHAURYASANYAL3

🛑 The Problem

When we invent a better algorithm for Health Scores (v0.2), we cannot simply drop the v0.1 data from the database. If we do, the live dashboard will crash for all users until the Inngest workers finish recalculating millions of rows (which could take hours). We need a zero-downtime strategy.

💡 The Solution

Implement the 'Expand and Contract' database migration pattern.

🛠️ Implementation Details

  1. Expand: Add a new column health_score_v2 to the schema. Deploy this harmless change.
  2. Migrate Data: Run a background script that calculates the v0.2 score for all repos and saves it to the new column.
  3. Switch Reads: Update the frontend Next.js code to read from health_score_v2. Deploy.
  4. Contract: Write a final Drizzle migration to drop the old health_score_v1 column.

✅ Acceptance Criteria

  • The procedure is fully documented.
  • No user experiences a 500 error or missing data during the transition.

Ready to tackle this? Comment .take below to get automatically assigned!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions