Skip to content

t3663: refactor(memory): extract pattern_metadata DDL to eliminate schema duplication#4521

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

t3663: refactor(memory): extract pattern_metadata DDL to eliminate schema duplication#4521
alex-solovyev merged 1 commit intomainfrom
bugfix/t3663-common-sh-schema-dedup

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

Summary

Addresses PR #1629 review feedback (gemini, medium severity) — pattern_metadata CREATE TABLE DDL was duplicated between init_db() and migrate_db() in .agents/scripts/memory/_common.sh.

Changes

  • Extracted pattern_metadata DDL into _create_pattern_metadata_table() — a single authoritative function
  • init_db() calls _create_pattern_metadata_table() after the main heredoc (fresh databases)
  • migrate_db() calls _create_pattern_metadata_table() inside the has_pattern_metadata == "0" guard (existing databases upgrading from pre-t1095 schema)
  • Backfill logic in migrate_db() is unchanged — only the inline CREATE TABLE block is replaced with the helper call
  • Finding 2 (hardcoded PATTERN_TYPES_SQL string) was already resolved in ffa983cc — confirmed $PATTERN_TYPES_SQL from shared-constants.sh is used

Verification

  • ShellCheck: zero violations
  • Behaviour: identical — CREATE TABLE IF NOT EXISTS is idempotent; both code paths produce the same schema

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

Warning

Rate limit exceeded

@alex-solovyev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3db6e71c-6d6f-4d69-9ef0-8c1e1b473e82

📥 Commits

Reviewing files that changed from the base of the PR and between b5bcb50 and 47520f8.

📒 Files selected for processing (1)
  • .agents/scripts/memory/_common.sh
✨ 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-common-sh-schema-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.

…plication (t3663)

PR #1629 review (gemini) flagged that the pattern_metadata CREATE TABLE DDL
was duplicated between init_db() and migrate_db(). The reviewer's guidance:
schema creation belongs in init_db(); migrate_db() should use ALTER TABLE or
existence checks, not full DDL.

Fix: extract DDL into _create_pattern_metadata_table() — a single authoritative
function called from both init_db() (fresh databases) and migrate_db() (existing
databases upgrading from pre-t1095 schema). The backfill logic in migrate_db()
is unchanged; only the inline CREATE TABLE block is replaced with a helper call.

Finding 2 (PATTERN_TYPES_SQL constant) was already resolved in ffa983c —
migrate_db() already uses $PATTERN_TYPES_SQL from shared-constants.sh.

ShellCheck: zero violations.

Closes #3663
@alex-solovyev alex-solovyev force-pushed the bugfix/t3663-common-sh-schema-dedup branch from d967c25 to 47520f8 Compare March 14, 2026 00:31
@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:31:45 UTC 2026: Code review monitoring started
Sat Mar 14 00:31:46 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:31:48 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@alex-solovyev alex-solovyev merged commit 48faa23 into main Mar 14, 2026
12 checks passed
@alex-solovyev alex-solovyev deleted the bugfix/t3663-common-sh-schema-dedup branch March 14, 2026 00:33
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