refactor: move baseline schema into migration v1#36
Conversation
Fixes #21 - Schema definition was split between createTables() and migrations. Changes: - createTables() now only creates schema_migrations table - All table/index creation moved into migration v1's up() function - Migrations are now the single source of truth for schema - Added architecture documentation in getMigrations() Migration safety: - Uses IF NOT EXISTS for idempotency - Existing databases already have v1 recorded (migration skips) - Fresh databases run migration v1 to create all tables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
User description
Summary
Fixes #21 - Makes migrations the single source of truth for database schema.
Problem
Schema was previously defined in two places:
createTables()- Created all tables directlyThis violated database migration best practices and made schema evolution harder to track.
Solution
createTables()now only createsschema_migrationstableup()functionMigration Safety
IF NOT EXISTS(idempotent)Test plan
🤖 Generated with Claude Code
PR Type
Enhancement
Description
Move all table/index creation from
createTables()into migration v1Establish migrations as single source of truth for schema
Ensure fresh and existing databases follow same code path
Add architecture documentation explaining migration safety
Diagram Walkthrough
File Walkthrough
database.ts
Consolidate schema definition into migration v1src/implementations/database.ts
createTables()methodtasks,task_output,task_dependencies)and indexes into migration v1's
up()functioncreateTables()to only createschema_migrationstable andapply pending migrations
getMigrations()documentation with architecture notes onmigration safety and idempotency