Skip to content

Commit fa0b2b7

Browse files
committed
fix: support d1 local migrations
1 parent d60fa8f commit fa0b2b7

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

playground/nuxt.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ export default defineNuxtConfig({
1717
'/cached': { prerender: true }
1818
},
1919

20-
compatibilityDate: '2025-09-09',
20+
compatibilityDate: '2025-12-11',
2121

2222
nitro: {
23+
preset: 'cloudflare-module',
2324
experimental: {
2425
websocket: true
2526
}

src/cache/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function resolveCacheConfig(hub: HubConfig): ResolvedCacheConfig | false
2323

2424
// Cloudflare KV cache binding
2525
if (hub.hosting.includes('cloudflare')) {
26-
let driver: string = resolve('cache/runtime/cloudflare-driver')
26+
let driver: string = resolve('cache/runtime/cloudflare-driver.mjs')
2727
if (isWindows) {
2828
driver = pathToFileURL(driver).href
2929
}

src/db/lib/migrations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function applyDatabaseMigrations(hub: ResolvedHubConfig, db: any) {
1616
const migrationsStorage = useDatabaseMigrationsStorage(hub)
1717
const dialect = hub.db.dialect
1818
const execute = dialect === 'sqlite' ? 'run' : 'execute'
19-
const getRows = (result: any) => (dialect === 'mysql' ? result[0] : result.rows || result)
19+
const getRows = (result: any) => (dialect === 'mysql' ? result[0] : result.results || result.rows || result) || []
2020

2121
const createMigrationsTableQuery = getCreateMigrationsTableQuery({ dialect: hub.db.dialect })
2222
log.debug('Creating migrations table if not exists...')

src/db/runtime/plugins/migrations.dev.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { ResolvedHubConfig } from '../../../types'
22
import { applyDatabaseMigrations, applyDatabaseQueries } from '../../lib/migrations'
33
// @ts-expect-error - Generated at runtime
44
import { db } from 'hub:db'
5-
// @ts-expect-error - Generated at runtime
65
import { defineNitroPlugin, useRuntimeConfig } from '#imports'
76

87
export default defineNitroPlugin(async () => {

0 commit comments

Comments
 (0)