Skip to content

t3663: refactor(memory): remove duplicate pattern_metadata DDL from migrate_db#4509

Merged
alex-solovyev merged 1 commit intomainfrom
bugfix/t3663-memory-common-dedup
Mar 14, 2026
Merged

t3663: refactor(memory): remove duplicate pattern_metadata DDL from migrate_db#4509
alex-solovyev merged 1 commit intomainfrom
bugfix/t3663-memory-common-dedup

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

Summary

  • Removes the duplicated CREATE TABLE IF NOT EXISTS pattern_metadata DDL from migrate_db() — the authoritative schema definition lives in init_db() (as recommended in PR t1095: Extend pattern tracker schema with strategy, quality, failure_mode, and token columns #1629 review)
  • Replaces the guarded if has_pattern_metadata == 0 block with an unconditional idempotent CREATE TABLE IF NOT EXISTS (no functional change — the statement is a no-op if the table exists)
  • Improves the backfill query to only count/insert records not already in pattern_metadata, avoiding misleading log output on re-runs
  • Adds a comment in migrate_db pointing to init_db as the authoritative schema location

What was not changed

Finding 2 from the PR #1629 review (hardcoded PATTERN_TYPES string) was already fixed in commit ffa983cc — the code already uses $PATTERN_TYPES_SQL from shared-constants.sh.

Verification

  • shellcheck .agents/scripts/memory/_common.sh — zero violations
  • Logic is functionally equivalent: CREATE TABLE IF NOT EXISTS is idempotent; the backfill and ALTER TABLE migrations are preserved

Closes #3663

…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
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 14, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • no-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b749975b-04e2-4414-b49f-f9e598a5b177

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t3663-memory-common-dedup
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the refactor Auto-created from TODO.md tag label Mar 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 414 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sat Mar 14 00:13:00 UTC 2026: Code review monitoring started
Sat Mar 14 00:13:01 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 414

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 414
  • VULNERABILITIES: 0

Generated on: Sat Mar 14 00:13:03 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@alex-solovyev alex-solovyev merged commit 23f40a9 into main Mar 14, 2026
19 checks passed
@alex-solovyev alex-solovyev deleted the bugfix/t3663-memory-common-dedup branch March 14, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quality-debt: .agents/scripts/memory/_common.sh — PR #1629 review feedback (medium)

2 participants