Migrate from Notion to PlanetScale Postgres#2216
Closed
brianlovin wants to merge 13 commits intomainfrom
Closed
Conversation
Replace Notion as the CMS with PlanetScale Postgres via Drizzle ORM. All 10 data types (speaking, listening, stack, good-websites, writing, TIL, AMA, design-details, app-dissection) now read from Postgres. - Add Drizzle schema, client, and query files for all data types - Add migration scripts for each data type (scripts/migrate-*.ts) - Add blocks-to-markdown converter for rich content migration - Add MarkdownContent component (react-markdown + remark-gfm) - Split lib files into client-safe (.ts) and server-only (.server.ts) - Delete src/lib/notion/, renderBlocks, schemas/, and Notion-only routes - Move @notionhq/client to devDependencies (migration scripts only) - Create self-contained scripts/lib/notion.ts for migration scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enables Next.js component-level caching with appropriate cache lifetimes (minutes for listening, hours for writing/TIL/AMA, days for app-dissection/design-details/speaking) and cache tags for on-demand revalidation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace React.cache() wrappers with Next.js "use cache" directive for server aggregators and data fetchers. Unifies caching strategy across the codebase and enables tag-based revalidation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Turn on Next.js cacheComponents for component-level caching. Add Suspense boundaries around async server components and client layouts to support prerendering. Skip SWR fetches during SSR to avoid uncached data access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove force-dynamic and revalidate exports now that "use cache" handles freshness. Add generateStaticParams to writing, TIL, and app-dissection detail pages for build-time prerendering. Use seeded random for stable "Read next" suggestions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add POST /api/revalidate endpoint for external cache invalidation with secret-based auth. Call revalidateTag after AMA question creation and writing short ID generation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split numbers page into a server wrapper with Suspense and a "use client" component so the page can be statically prerendered. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Expose createdAt in writing, TIL, and app-dissection query types so pages can fall back when publishedAt is empty. Add a direct getStackItemBySlug query to avoid fetching the full stack list. Guard AMA lookups with an isUuid check to prevent invalid UUID errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parse cursor/limit with Number.parseInt and reject out-of-range values. Add platform length cap on /api/stacks and UUID check on /api/til/[id]. Lower all API cache durations from 24 hours to 1 hour to keep data fresher after the Postgres migration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pages and RSS feeds now use publishedAt || createdAt so entries without a publishedAt still render a valid date. Date parsing is guarded against invalid values. getStackBySlug now queries by slug directly instead of fetching all items and filtering client-side. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
scripts/seed-local.ts populates all tables with minimal test data so the site can run locally without a production database or Notion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Replace node-postgres (pg) with postgres.js to fix "Connection closed" errors during static generation. The pg driver's Pool doesn't recover from server-initiated connection closes during Next.js builds. postgres.js with prepare: false handles this correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"use cache"directives and tag-based revalidationsrc/lib/notion/(client, queries, mutations, blocks, cache, types) — ~2,000 lines removedscripts/migrate-*.ts) to pull data from Notion into Postgresscripts/seed-local.tsfor local dev without production DBrenderBlocks(Notion block tree) toMarkdownContent(stored markdown)generateStaticParamsfor static generation of content pages/api/revalidate) with tag-based cache invalidationcreatedAtwhenpublishedAtis missing for robust date rendering@notionhq/clientkept as devDependency only (used by migration scripts)Net: -1,034 lines (4,093 added / 5,127 removed across 124 files)
Test plan
/writing/rss.xml,/til/rss.xml,/app-dissection/rss.xml,/ama/rss.xml)bun run buildpasses (note: seed data in prod DB currently causes prerender failures onseed-app-*pages — clean those before merge)🤖 Generated with Claude Code