Skip to content

update drizzle??#111

Merged
fennifith merged 10 commits intoplayfulprogramming:mainfrom
LadyBluenotes:drizzle-up
Feb 10, 2026
Merged

update drizzle??#111
fennifith merged 10 commits intoplayfulprogramming:mainfrom
LadyBluenotes:drizzle-up

Conversation

@LadyBluenotes
Copy link
Contributor

@LadyBluenotes LadyBluenotes commented Feb 5, 2026

update dependencies and add migration for post_images and url_metadata tables

per #89

Summary by CodeRabbit

  • Chores
    • Upgraded DB tooling and package manager versions; adjusted DB-related dependency listings.
  • New Features
    • Exposed a centralized set of DB relations in the public API for clearer relational navigation.
  • Bug Fixes
    • Simplified internal database query usage in a couple of routes (no behavioral changes).
  • Documentation
    • Removed outdated snapshot/journal files and added multiple updated full schema snapshots.
  • Migrations
    • Made table creation idempotent and updated/added schema constraints and columns.

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds multiple Drizzle schema snapshots, deletes legacy meta snapshots and journal, upgrades Drizzle tooling, extracts relation definitions into a new exported relations module and wires it into DB initialization, removes in-file relation exports, adjusts several migrations, and simplifies two ORM query where-clauses.

Changes

Cohort / File(s) Summary
New Drizzle snapshots
packages/db/drizzle/20250619151208_gigantic_epoch/snapshot.json, packages/db/drizzle/20250719232913_broad_archangel/snapshot.json, packages/db/drizzle/20250908005834_panoramic_carmella_unuscione/snapshot.json, packages/db/drizzle/20260120005415_famous_silver_samurai/snapshot.json
Adds timestamped Postgres schema snapshot JSONs capturing tables, columns, primary keys, foreign keys, and schema metadata.
Removed meta snapshots & journal
packages/db/drizzle/meta/0000_snapshot.json, .../0001_snapshot.json, .../0002_snapshot.json, .../0003_snapshot.json, packages/db/drizzle/meta/_journal.json
Deletes legacy snapshot files and the drizzle migration journal JSON.
Migration SQL updates
packages/db/drizzle/.../migration.sql (multiple folders)
Makes CREATE TABLE idempotent (IF NOT EXISTS), alters constraints/columns (drop NOT NULL, add new columns), redefines foreign keys, removes/drops table(s) and adds new columns; several migrations updated.
DB client & relations
packages/db/src/client.ts, packages/db/src/relations.ts, packages/db/src/index.ts
Adds relations module (defineRelations), re-exports it, and passes relations into drizzle initialization: drizzle({ client: pool, schema, relations }).
Removed in-file relation exports
packages/db/src/schema/collections.ts, packages/db/src/schema/posts.ts
Removes previously exported relation helpers and their relations imports from schema files.
Query where-clause simplifications
apps/api/src/routes/tasks/post-images.ts, apps/api/src/routes/tasks/url-metadata.ts
Replaces predicate form where: (t) => eq(t.field, value) with direct object match where: { field: value }.
Dependency & workspace updates
packages/db/package.json, pnpm-workspace.yaml, apps/api/package.json
Bumps drizzle-kit devDependency and workspace drizzle-orm reference to 1.0.0-beta.15-859cf75; removes drizzle-orm from apps/api dependencies.
Project metadata
package.json
Updates packageManager from pnpm@10.6.1 to pnpm@10.28.2.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant App as App (startup / API)
participant Relations as Relations module
participant DBClient as DB client (drizzle)
participant Postgres as Postgres DB
Note over App,Relations: Startup wiring
App->>Relations: import relations
App->>DBClient: drizzle({ client: pool, schema, relations })
DBClient->>Relations: register relation graph
App->>DBClient: execute query (schema-aware)
DBClient->>Postgres: SQL (with relation metadata)
Postgres-->>DBClient: results
DBClient-->>App: query responses

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic, using '??' which conveys no meaningful information about the substantial schema changes, dependency updates, and migration work in this changeset. Replace with a more descriptive title that captures the main change, such as 'Upgrade drizzle-orm and drizzle-kit with schema migrations' or 'Refactor drizzle schema relations and add new migrations'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pnpm-workspace.yaml`:
- Line 14: The pnpm workspace bumped the package drizzle-orm to
^1.0.0-beta.15-859cf75; before merging, run the full test suite and CI against
that beta, review the drizzle-orm 1.0.0-beta changelog for breaking API changes,
update any call sites to the new API, or revert/pin the dependency back to the
last stable version (e.g., ^0.44.6) in the workspace file if you cannot confirm
compatibility, and then re-run integration tests and dependency security checks
to ensure the app remains stable.
🧹 Nitpick comments (1)
packages/db/package.json (1)

22-22: Version specifier inconsistency between drizzle-orm and drizzle-kit.

drizzle-kit is pinned to an exact version (1.0.0-beta.15-859cf75) while drizzle-orm in the workspace catalog uses a caret (^1.0.0-beta.15-859cf75). This inconsistency could lead to version drift over time.

Consider aligning the version specifiers—either pin both or use caret for both—to ensure drizzle-orm and drizzle-kit stay in sync.

Co-authored-by: James Fenn <me@jfenn.me>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/db/src/client.ts`:
- Line 12: The drizzle client is initialized without the relations object so
relational queries (db.query.*) won't resolve; import the relations defined in
relations.ts (e.g., the exported symbol relations) and pass it into the
drizzle() initializer alongside client and schema (update the export const db =
drizzle(...) call to include relations) so defineRelations-based relational
queries work correctly.

Copy link
Member

@fennifith fennifith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a "do not merge" notice here because we'll need to run some manual migrations on fly when it deploys

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/db/drizzle/20250719232913_broad_archangel/migration.sql`:
- Around line 4-5: The ALTER TABLE statements on "post_images" add NOT NULL
columns "fetched_at" and "error" without defaults which will fail on non-empty
tables; fix by either (A) add them as nullable, backfill existing rows, then
ALTER to SET NOT NULL (use "fetched_at" and "error" names for backfill/update
and then set NOT NULL), or (B) add them with sensible DEFAULTs (e.g., DEFAULT
now() for "fetched_at" and DEFAULT false for "error") and then optionally DROP
DEFAULTs after the migration; implement one of these approaches for the ALTER
TABLE changes referencing "post_images", "fetched_at", and "error".
🧹 Nitpick comments (1)
packages/db/drizzle/20260120005415_famous_silver_samurai/migration.sql (1)

5-6: All existing posts will get collection_order = 0 — consider a backfill.

Since collection_order defaults to 0 and is NOT NULL, every existing post that already belongs to a collection will share the same order value. If ordering matters, you'll need a follow-up data migration to assign meaningful order values; otherwise the sort order among existing collection posts will be arbitrary.

Comment on lines +4 to +5
ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "fetched_at" timestamp with time zone NOT NULL;--> statement-breakpoint
ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "error" boolean NOT NULL; No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Adding NOT NULL columns without a DEFAULT will fail on non-empty tables.

If post_images already contains rows, PostgreSQL will reject these ALTER TABLE … ADD COLUMN statements because it cannot assign a value to existing rows for a NOT NULL column that has no default. The IF NOT EXISTS guard only prevents adding a duplicate column — it does not help here.

A typical fix is to either:

  1. Add the columns as nullable first, backfill, then set NOT NULL, or
  2. Provide a sensible DEFAULT (e.g., DEFAULT now() for fetched_at, DEFAULT false for error).
🐛 Proposed fix — add defaults
-ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "fetched_at" timestamp with time zone NOT NULL;--> statement-breakpoint
-ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "error" boolean NOT NULL;
+ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "fetched_at" timestamp with time zone NOT NULL DEFAULT now();--> statement-breakpoint
+ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "error" boolean NOT NULL DEFAULT false;

If these defaults should not persist on future inserts, you can drop them after the migration:

ALTER TABLE "post_images" ALTER COLUMN "fetched_at" DROP DEFAULT;
ALTER TABLE "post_images" ALTER COLUMN "error" DROP DEFAULT;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "fetched_at" timestamp with time zone NOT NULL;--> statement-breakpoint
ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "error" boolean NOT NULL;
ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "fetched_at" timestamp with time zone NOT NULL DEFAULT now();--> statement-breakpoint
ALTER TABLE "post_images" ADD COLUMN IF NOT EXISTS "error" boolean NOT NULL DEFAULT false;
🤖 Prompt for AI Agents
In `@packages/db/drizzle/20250719232913_broad_archangel/migration.sql` around
lines 4 - 5, The ALTER TABLE statements on "post_images" add NOT NULL columns
"fetched_at" and "error" without defaults which will fail on non-empty tables;
fix by either (A) add them as nullable, backfill existing rows, then ALTER to
SET NOT NULL (use "fetched_at" and "error" names for backfill/update and then
set NOT NULL), or (B) add them with sensible DEFAULTs (e.g., DEFAULT now() for
"fetched_at" and DEFAULT false for "error") and then optionally DROP DEFAULTs
after the migration; implement one of these approaches for the ALTER TABLE
changes referencing "post_images", "fetched_at", and "error".

@fennifith fennifith added this pull request to the merge queue Feb 10, 2026
Merged via the queue into playfulprogramming:main with commit 16cd053 Feb 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants