nuxt-hub / core

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

Drizzle ORM changes fields and migration fails #155

Open LBC000 opened 2 weeks ago

LBC000 commented 2 weeks ago

Describe the bug Drizzle ORM changes fields and migration fails

Steps to reproduce Steps to reproduce the behavior:

  1. Change schema.ts usersAdmin. add email field
  2. Run npm run db:generate; "db:generate": "drizzle-kit generate"
  3. Rerun: npx nuxt dev --remote
  4. Database migrations failed [POST] "https://xxxxx.cloudflare-nuxthub-02.pages.dev/api/_hub/database/batch": 500

at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async $fetch2 (node_modules/.pnpm/ofetch@1.3.4/node_modules/ofetch/dist/shared/ofetch.37386b05.mjs:268:15) at SQLiteD1Session.batch (nodemodules/.pnpm/drizzle-orm@0.31.2@cloudflare+workers-types@4.20240605.0_@opentelemetry+api@1.8.0/node_modules/src/d1/session.ts:82:24) at migrate (nodemodules/.pnpm/drizzle-orm@0.31.2@cloudflare+workers-types@4.20240605.0_@opentelemetry+api@1.8.0/node_modules/src/d1/migrator.ts:51:3) at (server/plugins/migrations.ts:8:1)

Expected behavior Can change fields without error, d1 changes synchronously

image
Atinux commented 2 weeks ago

Do you have the error locally without the --remote @LBC000 ?

LBC000 commented 2 weeks ago

Do you have the error locally without the @LBC000 ?--remote

The first time I ran npm run db:generate; "db:generate": "drizzle-kit generate". Then I started the project, and D1 generated the table correctly. This proves that the remote link is correct. But when I want to add a new field, an error is reported, as described above