db snapshots fixed#219
Conversation
📝 WalkthroughWalkthroughAdds a new database migration snapshot (0014) containing full schema definitions for tables, indexes, foreign keys, enums, and RLS flags, updates the prevId reference in the 0012 snapshot to chain to the new migration, and updates the journal's timestamp entry for migration 14. ChangesDatabase migration snapshot addition
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/db/migrations/meta/0014_snapshot.json`:
- Around line 753-810: Add a composite primary key or unique constraint to the
join-table FK columns so duplicate links cannot be inserted. Update the snapshot
entries for bible_books and project_unit_bible_books in the migration metadata
to define uniqueness across their foreign key pairs, matching the existing table
structure and the join-table semantics.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: fbb95e7d-f671-49f3-9b26-c6a064cd3c10
📒 Files selected for processing (3)
src/db/migrations/meta/0012_snapshot.jsonsrc/db/migrations/meta/0014_snapshot.jsonsrc/db/migrations/meta/_journal.json
| "public.bible_books": { | ||
| "name": "bible_books", | ||
| "schema": "", | ||
| "columns": { | ||
| "bible_id": { | ||
| "name": "bible_id", | ||
| "type": "integer", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| }, | ||
| "book_id": { | ||
| "name": "book_id", | ||
| "type": "integer", | ||
| "primaryKey": false, | ||
| "notNull": true | ||
| }, | ||
| "created_at": { | ||
| "name": "created_at", | ||
| "type": "timestamp", | ||
| "primaryKey": false, | ||
| "notNull": false, | ||
| "default": "now()" | ||
| }, | ||
| "updated_at": { | ||
| "name": "updated_at", | ||
| "type": "timestamp", | ||
| "primaryKey": false, | ||
| "notNull": false, | ||
| "default": "now()" | ||
| } | ||
| }, | ||
| "indexes": {}, | ||
| "foreignKeys": { | ||
| "bible_books_bible_id_bibles_id_fk": { | ||
| "name": "bible_books_bible_id_bibles_id_fk", | ||
| "tableFrom": "bible_books", | ||
| "tableTo": "bibles", | ||
| "columnsFrom": ["bible_id"], | ||
| "columnsTo": ["id"], | ||
| "onDelete": "no action", | ||
| "onUpdate": "no action" | ||
| }, | ||
| "bible_books_book_id_books_id_fk": { | ||
| "name": "bible_books_book_id_books_id_fk", | ||
| "tableFrom": "bible_books", | ||
| "tableTo": "books", | ||
| "columnsFrom": ["book_id"], | ||
| "columnsTo": ["id"], | ||
| "onDelete": "no action", | ||
| "onUpdate": "no action" | ||
| } | ||
| }, | ||
| "compositePrimaryKeys": {}, | ||
| "uniqueConstraints": {}, | ||
| "policies": {}, | ||
| "checkConstraints": {}, | ||
| "isRLSEnabled": false | ||
| }, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Add uniqueness to the association tables.
bible_books and project_unit_bible_books are pure join tables, but neither declares a composite PK or unique constraint on its FK columns. That allows duplicate links to be inserted and can skew downstream joins/counts.
Also applies to: 1905-1977
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/db/migrations/meta/0014_snapshot.json` around lines 753 - 810, Add a
composite primary key or unique constraint to the join-table FK columns so
duplicate links cannot be inserted. Update the snapshot entries for bible_books
and project_unit_bible_books in the migration metadata to define uniqueness
across their foreign key pairs, matching the existing table structure and the
join-table semantics.
db snapshots fixed for 12 and 14
Summary by CodeRabbit