Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tiny-ways-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

auto create table for D1NextModeTagCache
14 changes: 6 additions & 8 deletions examples/overrides/d1-tag-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"d1:clean": "wrangler d1 execute NEXT_CACHE_D1 --command \"DROP TABLE IF EXISTS revalidations\"",
"d1:setup": "wrangler d1 execute NEXT_CACHE_D1 --command \"CREATE TABLE IF NOT EXISTS revalidations (tag TEXT NOT NULL, revalidatedAt INTEGER NOT NULL, UNIQUE(tag) ON CONFLICT REPLACE);\"",
"build:worker": "pnpm d1:clean && pnpm opennextjs-cloudflare build && pnpm d1:setup",
"build:worker": "pnpm opennextjs-cloudflare build",
"preview:worker": "pnpm opennextjs-cloudflare preview",
"preview": "pnpm build:worker && pnpm preview:worker",
"e2e": "playwright test -c e2e/playwright.config.ts"
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0",
"next": "15.1.7"
"react": "catalog:e2e",
"react-dom": "catalog:e2e",
"next": "catalog:e2e"
},
"devDependencies": {
"@opennextjs/cloudflare": "workspace:*",
"@playwright/test": "catalog:",
"@types/node": "catalog:",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react": "catalog:e2e",
"@types/react-dom": "catalog:e2e",
"typescript": "catalog:",
"wrangler": "catalog:"
}
Expand Down
16 changes: 16 additions & 0 deletions packages/cloudflare/src/cli/populate-cache/populate-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ export async function populateCache(
if (!config.dangerous?.disableTagCache && !config.dangerous?.disableIncrementalCache && tagCache) {
const name = await resolveCacheName(tagCache);
switch (name) {
case "d1-next-mode-tag-cache": {
logger.info("\nCreating D1 table if necessary...");

runWrangler(
options,
[
"d1 execute",
"NEXT_CACHE_D1",
`--command "CREATE TABLE IF NOT EXISTS revalidations (tag TEXT NOT NULL, revalidatedAt INTEGER NOT NULL, UNIQUE(tag) ON CONFLICT REPLACE);"`,
],
{ ...populateCacheOptions, logging: "error" }
);

logger.info("\nSuccessfully created D1 table");
break;
}
case "d1-tag-cache": {
logger.info("\nPopulating D1 tag cache...");

Expand Down
Loading