content icon indicating copy to clipboard operation
content copied to clipboard

Help please, Tables are not created in Cloudflare D1 when deploying

Open agotfredsen82 opened this issue 9 months ago • 8 comments

Environment


  • Operating System: Darwin
  • Node Version: v22.14.0
  • Nuxt Version: 3.15.1
  • CLI Version: 3.23.1
  • Nitro Version: 2.11.8
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

3.4.0

Reproduction

nitro: { preset: "cloudflare-pages", },

hub: { database: true, },

content: { database: { type: 'd1', binding: 'DB' } },

Description

I am using nitro preset Cloudflare Worker

D1 binding works fine BUT tables are never created for Nuxt / content In D1 . ? So I get a blank website

in log on Cloduflare Dashboard in D1 I see things like SELECT * FROM _content_info WHERE id = ? SELECT * FROM _content_content WHERE ("path" = '/portfolio/fullscreen')

but there are not any tables to get any data from , simply the tables are not created on deploy ?

only table I see is _hub_migration that seems to be able to create its tables on deploy CREATE TABLE IF NOT EXISTS _hub_migrations ( id INTEGER PRIMARY KEY A etc etc

In my Github workflows I have

yarn build:web - > "build": "nuxt build", npx wrangler pages deploy

I have tried for hours trying to get this working , help please

Additional context

No response

Logs


agotfredsen82 avatar Mar 30 '25 09:03 agotfredsen82

Hey, with the latest updates in the eco-system, the Cloudflare context was lost in Nuxt Content APIs, and that caused the issue. The fix is done in https://github.com/nuxt/content/pull/3275

You can try the fix using npm i https://pkg.pr.new/@nuxt/content@453ba2e while waiting for the next release.

larbish avatar Mar 30 '25 09:03 larbish

Thanks @larbish but it does not seem to fix tables are still not created ? . to check that any db data is generated I also test running locally and see that after running Nuxt build the dist folder have a database folder with a queries folder with a content-database-001.sql that have the correct "data"

DROP TABLE IF EXISTS _content_info; CREATE TABLE IF NOT EXISTS _content_info (id TEXT PRIMARY KEY, "ready" BOOLEAN, "structureVersion" VARCHAR, "version" VARCHAR, "hash" TEXT UNIQUE); -- structure INSERT INTO _content_info VALUES ..... etc etc etc

but this is never run against D1 when I deploy running "build": "nuxt build",

my dev dev now has

"devDependencies": { "@nuxt/content": "https://pkg.pr.new/@nuxt/content@453ba2e",

using yarn ...

either fix is now working or my yarn is not using "@nuxt/content": "https://pkg.pr.new/@nuxt/content@453ba2e", correctly

any thing I can look after to see that its realy using the 453ba2e build ?

lock file says

"@nuxt/content@https://pkg.pr.new/@nuxt/content@453ba2e": version: 3.4.0 resolution: "@nuxt/content@https://pkg.pr.new/@nuxt/content@453ba2e" dependencies: ....

agotfredsen82 avatar Mar 30 '25 10:03 agotfredsen82

Hello @agotfredsen82, Is it possible to provide a simple reproduction using https://pkg.pr.new/@nuxt/content@453ba2e, a GitHub repository would be nice? In my test, it works as expected

farnabaz avatar Mar 31 '25 12:03 farnabaz

That's superb news!!! @farnabaz Your commit fixes it on my site (kestra-io/docs)

I was about to loose my mind. When do you expect a 3.4.1 release? next week? next month?

elevatebart avatar Apr 02 '25 15:04 elevatebart

@elevatebart The plan is to release next week

farnabaz avatar Apr 04 '25 10:04 farnabaz

@farnabaz The content@453ba2e fixed it for me too. Any updates on when we should expect the new version? Thanks!

MooseSaeed avatar Apr 16 '25 21:04 MooseSaeed

@MooseSaeed There are a few blockers for the release. We're working to provide fixes on upstream packages. I'll release as soon as those blocker are fixed.

farnabaz avatar Apr 17 '25 09:04 farnabaz

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jun 16 '25 10:06 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Jul 16 '25 11:07 github-actions[bot]