t3663: refactor(memory): remove duplicate pattern_metadata DDL from migrate_db#4509
Conversation
…db (t3663) The CREATE TABLE IF NOT EXISTS pattern_metadata block was duplicated between migrate_db() (lines 178-188) and init_db() (lines 508-516). Per reviewer feedback on PR #1629, schema creation should be authoritative in init_db; migrate_db should only ensure existence and handle ALTER TABLE migrations. Changes: - Remove the guarded if/log_info/log_success wrapper around the CREATE TABLE in migrate_db — the statement is now unconditional (idempotent via IF NOT EXISTS) - Add a comment pointing to init_db as the authoritative schema location - Improve backfill query to only count/insert records not already in pattern_metadata (avoids misleading log output on re-runs) - Preserve the estimated_cost ALTER TABLE migration for pre-t1114 databases Finding 2 (PATTERN_TYPES_SQL constant) was already fixed in ffa983c. Closes #3663
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Mar 14 00:13:03 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|



Summary
CREATE TABLE IF NOT EXISTS pattern_metadataDDL frommigrate_db()— the authoritative schema definition lives ininit_db()(as recommended in PR t1095: Extend pattern tracker schema with strategy, quality, failure_mode, and token columns #1629 review)if has_pattern_metadata == 0block with an unconditional idempotentCREATE TABLE IF NOT EXISTS(no functional change — the statement is a no-op if the table exists)pattern_metadata, avoiding misleading log output on re-runsmigrate_dbpointing toinit_dbas the authoritative schema locationWhat was not changed
Finding 2 from the PR #1629 review (hardcoded
PATTERN_TYPESstring) was already fixed in commitffa983cc— the code already uses$PATTERN_TYPES_SQLfromshared-constants.sh.Verification
shellcheck .agents/scripts/memory/_common.sh— zero violationsCREATE TABLE IF NOT EXISTSis idempotent; the backfill andALTER TABLEmigrations are preservedCloses #3663