Implement Phase 2: Database migrations and chat schema - #14
Merged
Conversation
Add custom migration system and chat persistence tables: **Migration Infrastructure (SNY-45):** - Created migration runner with transaction support and rollback - Migration tracking via schema_migrations table - CLI tools: npm run migrate, npm run migrate:status - Added allAsync() helper to dbHelpers for multi-row queries - Made createApp() async to support migration runner - Migrations are idempotent and work with :memory: databases **Schema Migrations:** - 001_baseline.js - Captures current users table schema - 002_chat_tables.js - Adds conversations, conversation_members, messages tables - Foreign keys with CASCADE DELETE for referential integrity - Performance indexes on conversation_id, created_at, deleted_at, user_id - Soft delete support via deleted_at column in messages **Chat Repositories (SNY-48):** - conversationRepository.js - 7 methods for conversation CRUD and membership - messageRepository.js - 7 methods for message CRUD with soft delete filtering - Follows existing userRepository pattern (async, db-first param, Promise-based) **Developer Tools (SNY-51):** - seed.js script creates test users (alice, bob, charlie) - Generates sample conversations and messages for local testing - npm run seed:reset for clean test data **Database Schema:** Tables: users, conversations, conversation_members, messages, schema_migrations Indexes: 3 performance indexes for query optimization Total files: 9 created, 5 modified All 59 tests passing. Zero breaking changes to existing functionality. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Add custom migration system and chat persistence tables:
Migration Infrastructure (SNY-45):
Schema Migrations:
Chat Repositories (SNY-48):
Developer Tools (SNY-51):
Database Schema:
Tables: users, conversations, conversation_members, messages, schema_migrations Indexes: 3 performance indexes for query optimization Total files: 9 created, 5 modified
All 59 tests passing. Zero breaking changes to existing functionality.