Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 21 additions & 5 deletions docs/content/docs/6.guides/3.ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ Unlike PostgreSQL or MySQL, where build-time migrations work because the databas

Run migrations before deployment using Wrangler or the NuxtHub CLI.

::warning
If you applied migrations with NuxtHub before v0.10 and you use Cloudflare D1, some rows in `_hub_migrations` may be missing the `.sql` suffix. Wrangler requires `.sql` in order to recognize the migration files.
::

Fix: Update the migration names in the `_hub_migrations` table to include the `.sql` suffix.

```sql
-- Preview affected rows
SELECT id, name FROM _hub_migrations WHERE name NOT LIKE '%.sql';

-- Append .sql
UPDATE _hub_migrations SET name = name || '.sql' WHERE name NOT LIKE '%.sql';
```

#### 1. Disable Build-Time Migrations

```ts [nuxt.config.ts]
Expand Down Expand Up @@ -119,7 +133,7 @@ Configure your `wrangler.jsonc` to use NuxtHub's migration table and output dire
"binding": "DB",
"database_id": "<database-id>",
"migrations_table": "_hub_migrations",
"migrations_dir": ".output/server/db/migrations/"
"migrations_dir": ".output/server/db/migrations/sqlite/"
}]
}
```
Expand All @@ -145,19 +159,21 @@ jobs:
- name: Install dependencies
run: pnpm install

# Run migrations BEFORE the build step
- name: Build
run: pnpm build

- name: Apply D1 Migrations
run: npx wrangler d1 migrations apply <database-name> --remote
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}

- name: Build
run: pnpm build
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

- name: Deploy
run: npx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

```

**Option B: Using `nuxt db migrate`**
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@
"db": "./cli/bin/nuxt-db.mjs"
},
"dependencies": {
"@cloudflare/workers-types": "^4.20251219.0",
"@nuxt/kit": "^4.2.2",
"@cloudflare/workers-types": "^4.20260214.0",
"@nuxt/kit": "^4.3.1",
"@uploadthing/mime-types": "^0.3.6",
"c12": "^3.3.3",
"chokidar": "^5.0.0",
"citty": "^0.1.6",
"citty": "^0.2.1",
"consola": "^3.4.2",
"defu": "^6.1.4",
"execa": "^9.6.1",
"get-port-please": "^3.2.0",
"h3": "^1.15.4",
"hookable": "6.0.1",
"mime": "^4.1.0",
"nypm": "^0.6.2",
"nypm": "^0.6.5",
"ofetch": "^1.5.1",
"pathe": "^2.0.3",
"pkg-types": "^2.3.0",
Expand All @@ -101,21 +101,21 @@
},
"devDependencies": {
"@nuxt/devtools": "^3.1.1",
"@nuxt/eslint-config": "^1.12.1",
"@nuxt/eslint-config": "^1.15.1",
"@nuxt/module-builder": "^1.0.2",
"@nuxt/schema": "^4.2.2",
"@nuxt/schema": "^4.3.1",
"@nuxt/test-utils": "3.21.0",
"@nuxthub/core": "link:",
"@types/node": "^25.0.3",
"better-sqlite3": "^12.5.0",
"@types/node": "^25.2.3",
"better-sqlite3": "^12.6.2",
"changelogen": "^0.6.2",
"destr": "^2.0.5",
"eslint": "^9.39.2",
"jiti": "^2.6.1",
"nitropack": "^2.12.9",
"nuxt": "^4.2.2",
"nitropack": "^2.13.1",
"nuxt": "^4.3.1",
"typescript": "^5.9.3",
"vitest": "^4.0.16",
"vue-tsc": "^3.1.8"
"vitest": "^4.0.18",
"vue-tsc": "^3.2.4"
}
}
4 changes: 4 additions & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export default defineNuxtConfig({

hub: {
db: 'sqlite',
// db: {
// dialect: 'sqlite',
// driver: 'd1'
// },
blob: true,
kv: true,
cache: true
Expand Down
31 changes: 16 additions & 15 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@
"preview": "nuxi preview"
},
"dependencies": {
"@electric-sql/pglite": "^0.3.14",
"@iconify-json/simple-icons": "^1.2.63",
"@libsql/client": "^0.15.15",
"@nuxt/ui": "^4.2.1",
"@electric-sql/pglite": "^0.3.15",
"@iconify-json/simple-icons": "^1.2.70",
"@libsql/client": "^0.17.0",
"@nuxt/ui": "^4.4.0",
"@nuxthub/core": "workspace:*",
"@upstash/redis": "^1.35.8",
"@vercel/blob": "^2.0.0",
"@vueuse/core": "^14.1.0",
"@vueuse/nuxt": "^14.1.0",
"@upstash/redis": "^1.36.2",
"@vercel/blob": "^2.2.0",
"@vueuse/core": "^14.2.1",
"@vueuse/nuxt": "^14.2.1",
"aws4fetch": "^1.0.20",
"drizzle-kit": "^0.31.8",
"drizzle-kit": "^0.31.9",
"drizzle-orm": "^0.45.1",
"ioredis": "^5.8.2",
"mysql2": "^3.15.3",
"nuxt": "4.2.2",
"nuxt-auth-utils": "^0.5.26",
"postgres": "^3.4.7",
"ioredis": "^5.9.3",
"mysql2": "^3.17.1",
"nuxt": "4.3.1",
"nuxt-auth-utils": "^0.5.28",
"postgres": "^3.4.8",
"tailwindcss": "^4.1.18",
"zod": "^4.2.1"
},
"devDependencies": {
"@nuxt/devtools": "latest"
"@nuxt/devtools": "latest",
"wrangler": "^4.65.0"
}
}
Loading
Loading