Skip to content

feat(db): add recommendation source account schema - #881

Merged
cristim merged 1 commit into
mainfrom
feat/recommendation-source-schema
Oct 15, 2026
Merged

cristim merged 1 commit into
mainfrom
feat/recommendation-source-schema

Conversation

@cristim

@cristim cristim commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Migration120 adds source_account_key from recommendation JSON and a unique index that includes it. The existing eleven-column index remains in place so current writers keep working. Rollback refuses to remove the new key when the old index is absent, and it preserves recommendation payloads.

Refs #799. This schema prerequisite leaves source-account collection, source-aware row IDs, consumer identity and exact Archera matching for the later foundation steps. The old index still rejects otherwise identical source variants. Real-account verification remains in #798.

Validation at fa5ff70b79c7bfb9b5178dcb5a5bd3d3845ede33: pinned Go1.26.9 build, migration race tests, golangci-lint2.10.1 and normal hooks pass. Two source passes and an exact-byte staged review are clean. Independent cold verification passed twice, exercised PostgreSQL17.11 migration119→120→119→120 and direct JSONB/upsert cases, and killed a scratch mutation that lowercased source identity.

Native evidence uses synthetic data in fresh owned local PostgreSQL clusters. Both clusters stopped afterward; no live provider or customer database verification is claimed.

Summary by CodeRabbit

  • Chores
    • Updated how recommendation records are indexed by source account. No end-user-visible changes.

@cristim cristim added effort/l Weeks triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/few Limited audience type/feat New capability labels Oct 15, 2026
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: f5c3ceb5-1da0-492d-b7f0-aa546d672a8c
📥 Commits

Reviewing files that changed from the base of the PR and between 64ec8b3 and fa5ff70.

📒 Files selected for processing: 3
  • internal/database/postgres/migrations/000120_recommendations_source_account.down.sql
  • internal/database/postgres/migrations/000120_recommendations_source_account.up.sql
  • internal/database/postgres/migrations/000120_recommendations_source_account_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

📝 Walkthrough

The migration adds a stored source_account_key column to recommendations and a unique index that includes the key. Its rollback checks for the legacy index before removing the new index and column. Integration tests cover key values, index behavior, and rollback.

Changes: Recommendation source-account key

Layer / File(s) Summary
Add and verify the source-account key
internal/database/postgres/migrations/000120_recommendations_source_account.up.sql, internal/database/postgres/migrations/000120_recommendations_source_account.down.sql, internal/database/postgres/migrations/000120_recommendations_source_account_test.go
The migration adds a generated key and unique index. Rollback checks for the legacy index before removing the new schema elements. Integration tests verify key derivation, payload preservation, index behavior, and rollback.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to fa5ff

No demonstrated issue prevents merging after normal checks. Plan the migration window with the production table size in mind.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding the recommendation source-account schema and related database migration.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cristim

cristim commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

The docstring coverage warning applies only to the migration test function. Its name and assertions describe the behavior, and the project avoids comments that repeat code. No public production API changed, so no redundant test docstring is added. The exact-head review reports no actionable findings.

@cristim
cristim merged commit 21910e3 into main Oct 15, 2026
26 checks passed
@cristim
cristim deleted the feat/recommendation-source-schema branch October 15, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/l Weeks impact/few Limited audience priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/feat New capability urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant