nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
802 stars 35 forks source link

Failing migration #149

Closed zAlweNy26 closed 3 weeks ago

zAlweNy26 commented 3 weeks ago

Describe the bug I don't understand what I am doing wrong in my project. I'm using the starter template (modified ofc) and following the documentation of Nuxt Hub for using Drizzle. The only difference (except for the tables) is the db dialect, postgresql. When I generate the migrations everything is ok, but then when I start the project, I see this error in console:

 ERROR  Database migrations failed D1_ERROR: near "(": syntax error at offset 144

  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at SQLiteD1Session.batch (node_modules/src/d1/session.ts:82:24)
  at migrate (node_modules/src/d1/migrator.ts:51:3)
  at <anonymous> (server/plugins/migrations.ts:8:1)
  at async Promise.all (index 0)
  at <anonymous> (node_modules/@nuxthub/core/dist/runtime/ready.dev.js:5:3)

So I'm unable to test the endpoints I created because it doesn't generate the tables. What am I doing wrong?

ra-jeev commented 3 weeks ago

But D1 is not a postgres database.

D1 is compatible with most SQLite’s SQL convention since it leverages SQLite’s query engine.

Also,

NuxtHub Database is a layer on top of Cloudflare D1, a serverless SQL database.

zAlweNy26 commented 3 weeks ago

But D1 is not a postgres database.

D1 is compatible with most SQLite’s SQL convention since it leverages SQLite’s query engine.

Also,

NuxtHub Database is a layer on top of Cloudflare D1, a serverless SQL database.

Ok thanks I missed that part. So there is no way to use postgres?

ra-jeev commented 3 weeks ago

I mean you could use some other postgres DB instead of Cloudflare D1 along with Drizzle. That is very much doable.

zAlweNy26 commented 3 weeks ago

I mean you could use some other postgres DB instead of Cloudflare D1 along with Drizzle. That is very much doable.

Can you point me to one of them? I'm not much into Cloudflare

ra-jeev commented 3 weeks ago

I mean you could use some other postgres DB instead of Cloudflare D1 along with Drizzle. That is very much doable.

Can you point me to one of them? I'm not much into Cloudflare

Cloudflare doesn't provide a Postgres db as far as I know. You could look at other third party providers or self host it.

Some providers are mentioned in this link

zAlweNy26 commented 3 weeks ago

Thank you so much, I'll look into that. So at the moment I'm unable to use postgres with NuxtHub?

ra-jeev commented 3 weeks ago

Thank you so much, I'll look into that. So at the moment I'm unable to use postgres with NuxtHub?

The D1 database part from NuxtHub, yes.

You can still use another Postgres service together with other things from NuxtHub, and host your app on Cloudflare pages using NuxtHub.

zAlweNy26 commented 3 weeks ago

Thanks for the clarification and patience, I will definitely do that!

Atinux commented 2 weeks ago

I agree with @ra-jeev said (and thank you for the help!)

For Postgres, Cloudflare worked on Hyperdrive that we plan to support as well in the future: https://developers.cloudflare.com/hyperdrive/

But honestly, D1 is a very powerful database that cover most cases

ra-jeev commented 2 weeks ago

Oooo, didn't know Cloudflare supports existing Postgres DBs. Thanks.