Skip to content

fix: migrate PR preview builds from D1 to PlanetScale#300

Open
zacjones93 wants to merge 2 commits intomainfrom
zac/fix-pr-build
Open

fix: migrate PR preview builds from D1 to PlanetScale#300
zacjones93 wants to merge 2 commits intomainfrom
zac/fix-pr-build

Conversation

@zacjones93
Copy link
Copy Markdown
Contributor

@zacjones93 zacjones93 commented Feb 24, 2026

Summary

  • Point PR preview stages at demo PlanetScale branch (was dev) so previews share demo data with no seeding needed
  • Remove dead D1 database seeding step from CI workflow
  • Add PlanetScale secrets to PR cleanup job so Alchemy can properly tear down Hyperdrive + PlanetScale password resources on PR close
  • Delete unused seed-pr.ts, seed-pr.sql, and db:seed:pr script

Test plan

  • PR deploy creates Hyperdrive binding pointing at demo PlanetScale branch
  • PR preview loads with demo data (no seed step needed)
  • PR close properly destroys all resources (Hyperdrive, PS password, KV, R2, Worker)

🤖 Generated with Claude Code


Summary by cubic

Migrate PR preview builds from D1 to PlanetScale/Hyperdrive and fix a D1 resource regression that broke PR builds. Previews now use the PlanetScale demo branch, share demo data without seeding, and clean up resources on close.

  • Migration
    • Point PR stages to PlanetScale "demo" branch; previews share demo data without seeding.
    • Remove D1 PR seed step and scripts, including db:seed:pr.
    • Add PlanetScale secrets to PR cleanup for full teardown; remove D1Database resource to unblock PR builds.

Written for commit 14997e5. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Removed automatic PR environment database seeding (seed script and seed data removed).
    • Updated PR deployment branch fallback to use "demo" for PR stages.
    • Added PlanetScale service credentials to deploy and destroy PR environment workflows.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 24, 2026

Walkthrough

The PR removes PR-specific database seeding (scripts and package script), removes the Seed PR Database CI step, adds PlanetScale secrets to deploy/destroy steps, and changes the PlanetScale branch fallback for PR stages from "dev" to "demo".

Changes

Cohort / File(s) Summary
CI/CD Workflow
​.github/workflows/deploy.yml
Removed "Seed PR Database" step; added PlanetScale secrets PLANETSCALE_SERVICE_TOKEN_ID, PLANETSCALE_SERVICE_TOKEN, PLANETSCALE_ORGANIZATION to Deploy with Alchemy and Destroy PR Environment steps.
Deployment IaC
apps/wodsmith-start/alchemy.run.ts
Removed D1Database import and D1 deployment block; changed PlanetScale branch-name fallback for PR stages from "dev" to "demo".
App Scripts / Package
apps/wodsmith-start/package.json
Removed db:seed:pr npm script.
PR Seed Files
apps/wodsmith-start/scripts/seed-pr.sql, apps/wodsmith-start/scripts/seed-pr.ts
Deleted: removed full SQL seed file and the TypeScript PR seeding runner (entire contents removed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hopped through files, seeds set free,

Gone the scripts, the CI spree.
PlanetScale tokens tucked in tight,
Branches favor "demo" in the night.
A tiny thump—deployments light. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: migrate PR preview builds from D1 to PlanetScale' clearly and concisely summarizes the main change: migrating the PR preview database infrastructure from D1 to PlanetScale, which is the primary objective of the entire changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zac/fix-pr-build

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
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

Copy link
Copy Markdown
Contributor

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/wodsmith-start/alchemy.run.ts (1)

225-241: ⚠️ Potential issue | 🟡 Minor

Update branch hierarchy comment to match PR → demo behavior.

Line 229 still says PR stages use the "dev" branch, but Line 240 now routes PR stages to "demo". This will confuse future edits.

📝 Suggested doc fix
 /**
  * PlanetScale branch hierarchy:
  * - prod  → "main" (production branch, no Branch resource needed)
  * - dev   → branches off main
  * - demo  → branches off main (parallel to dev)
- * - pr-N  → uses "dev" branch directly (no per-PR branch creation)
+ * - pr-N  → uses "demo" branch directly (no per-PR branch creation)
  */
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/wodsmith-start/alchemy.run.ts` around lines 225 - 241, Update the top
comment describing PlanetScale branch hierarchy to match the implemented logic:
change the line that currently says "pr-N → uses 'dev' branch directly (no
per-PR branch creation)" to indicate PR stages route to the "demo" branch (or
otherwise reflect that psBranchName computes pr-* to use "demo") so the
documentation matches the code paths involving branchConfig, isPrStage,
psBranchName and stage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/wodsmith-start/alchemy.run.ts`:
- Around line 225-241: Update the top comment describing PlanetScale branch
hierarchy to match the implemented logic: change the line that currently says
"pr-N → uses 'dev' branch directly (no per-PR branch creation)" to indicate PR
stages route to the "demo" branch (or otherwise reflect that psBranchName
computes pr-* to use "demo") so the documentation matches the code paths
involving branchConfig, isPrStage, psBranchName and stage.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08ee9ff and 7ed9568.

📒 Files selected for processing (5)
  • .github/workflows/deploy.yml
  • apps/wodsmith-start/alchemy.run.ts
  • apps/wodsmith-start/package.json
  • apps/wodsmith-start/scripts/seed-pr.sql
  • apps/wodsmith-start/scripts/seed-pr.ts
💤 Files with no reviewable changes (3)
  • apps/wodsmith-start/scripts/seed-pr.sql
  • apps/wodsmith-start/package.json
  • apps/wodsmith-start/scripts/seed-pr.ts

zacjones93 and others added 2 commits February 24, 2026 20:41
- Point PR stages at 'demo' PlanetScale branch instead of 'dev'
- Remove dead D1 seed step from deploy workflow
- Add PlanetScale secrets to cleanup job for proper teardown
- Delete unused seed-pr.ts and seed-pr.sql files
- Remove db:seed:pr script from package.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR #295 (Sentry) was based on a commit before the D1 removal and
reintroduced the D1Database("db") resource when merged to main.
This caused all PR preview builds to fail with 401 trying to create
a D1 database that's no longer needed post-PlanetScale migration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
apps/wodsmith-start/alchemy.run.ts (1)

225-230: Update the branch-hierarchy comment to match the new PR fallback.

psBranchName now routes PR stages to "demo" (Line 240), but the comment still says PR uses "dev". Please sync this to prevent future confusion.

✏️ Suggested fix
- * - pr-N  → uses "dev" branch directly (no per-PR branch creation)
+ * - pr-N  → uses "demo" branch directly (no per-PR branch creation)

Also applies to: 237-240

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/wodsmith-start/alchemy.run.ts` around lines 225 - 230, Update the
PlanetScale branch-hierarchy comment to reflect the new PR fallback: change the
line that currently reads "pr-N  → uses "dev" branch directly (no per-PR branch
creation)" to indicate that PR stages now route to "demo" instead (e.g., "pr-N →
routes to 'demo' (no per-PR branch creation)"); make the same update wherever
that old description appears near the psBranchName logic (reference symbol:
psBranchName) so the comment matches the runtime behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/wodsmith-start/alchemy.run.ts`:
- Around line 225-230: Update the PlanetScale branch-hierarchy comment to
reflect the new PR fallback: change the line that currently reads "pr-N  → uses
"dev" branch directly (no per-PR branch creation)" to indicate that PR stages
now route to "demo" instead (e.g., "pr-N → routes to 'demo' (no per-PR branch
creation)"); make the same update wherever that old description appears near the
psBranchName logic (reference symbol: psBranchName) so the comment matches the
runtime behavior.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ed9568 and 14997e5.

📒 Files selected for processing (5)
  • .github/workflows/deploy.yml
  • apps/wodsmith-start/alchemy.run.ts
  • apps/wodsmith-start/package.json
  • apps/wodsmith-start/scripts/seed-pr.sql
  • apps/wodsmith-start/scripts/seed-pr.ts
💤 Files with no reviewable changes (3)
  • apps/wodsmith-start/scripts/seed-pr.sql
  • apps/wodsmith-start/package.json
  • apps/wodsmith-start/scripts/seed-pr.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/deploy.yml

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.

1 participant