Repository navigation
chore(db): codify arecs updated_at ON UPDATE fix as migration 0001 - #369
Merged
Merged
Conversation
Production's `arecs` table (built by the legacy Sequelize migration) had `updated_at datetime NOT NULL` without ON UPDATE CURRENT_TIMESTAMP, so the recovery lifecycle timers (24h code TTL, 10-min stuck-claim self-heal in src/lib/recovery/lifecycle.ts) never re-armed on UPDATE. The column was fixed manually on production on 2026-10-08 (MAIN-57 follow-up, verified with a functional probe: UPDATE bumps updated_at, 0s skew). This codifies that change as a proper migration so dev environments and future rebuilds converge to the drizzle schema baseline instead of relying on hand-run SQL: - drizzle/0001_arecs_updated_at_on_update.sql — custom migration with the rationale and production-application record in its header - drizzle/meta/0001_snapshot.json + _journal.json — generated bookkeeping (drizzle-kit generate --custom, drizzle-kit check passes) - docs/DATABASE.md — timestamp-drift section now points at the migration instead of advising a manual SHOW CREATE TABLE check Verified against a legacy-shaped table in real MySQL 8: applying 0001 produces `updated_at datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP` and a subsequent UPDATE bumps the timestamp as expected. Production already has the column in this state; drizzle's journal marks 0001 applied after the first successful migrate run, so it will not re-execute there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Codifies the
arecs.updated_atON UPDATE fix (applied manually to production on 2026-10-08, MAIN-57 follow-up) as a proper drizzle migration, so dev environments and future rebuilds converge to the schema baseline instead of relying on hand-run SQL.drizzle/0001_arecs_updated_at_on_update.sql— custom migration (drizzle-kit generate --custom):ALTER TABLE arecs MODIFY updated_at datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP, with full rationale in the header (legacy Sequelize migration declared the timestamps NOT NULL without DB defaults; the recovery lifecycle's 24h code TTL and 10-minute stuck-claim self-heal readupdated_atas their inactivity timer)drizzle/meta/0001_snapshot.json+_journal.json— generated bookkeepingdocs/DATABASE.md— timestamp-drift section now points at the migration instead of advising a manualSHOW CREATE TABLEcheckVerification
drizzle-kit checkpasses;pnpm type-checkpassesarecstable (updated_at datetime NOT NULL, no ON UPDATE), applied 0001 → column becomesNOT NULL ON UPDATE CURRENT_TIMESTAMP, and a subsequent UPDATE bumpsupdated_attoNOW()(0s skew)