Skip to content

Commit ee18fca

Browse files
committed
chore: add shared hub:database:schema
1 parent 9055a22 commit ee18fca

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

playground/app/pages/database.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<script setup>
1+
<script setup lang="ts">
22
const loading = ref(false)
33
const newTodo = ref('')
44
const newTodoInput = ref(null)
55
66
const toast = useToast()
7-
const { data: todos } = await useFetch('/api/todos', {
7+
const { data: todos } = await useFetch<Todo[]>('/api/todos', {
88
deep: true
99
})
1010

playground/shared/types/db.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { comments, pages, todos } from 'hub:database:schema'
2+
3+
export type Comment = typeof comments.$inferSelect
4+
export type Page = typeof pages.$inferSelect
5+
export type Todo = typeof todos.$inferSelect

src/features/database.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ async function generateDatabaseSchema(nuxt: Nuxt, hub: ResolvedHubConfig) {
179179
filename: 'hub/database/schema.d.ts',
180180
write: true,
181181
getContents: () => `export * from './schema.mjs'`
182-
}, { nitro: true })
182+
}, { shared: true })
183183

184-
nuxt.options.nitro.alias ||= {}
185-
nuxt.options.nitro.alias['hub:database:schema'] = schemaTemplate.dst
184+
nuxt.options.alias ||= {}
185+
nuxt.options.alias['hub:database:schema'] = schemaTemplate.dst
186186
}
187187

188188
async function setupDatabaseClient(nuxt: Nuxt, hub: ResolvedHubConfig) {

src/utils/database.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,10 @@ export async function applyBuildTimeMigrations(nitro: Nitro, hub: ResolvedHubCon
104104
if (migrationsApplied === false) {
105105
process.exit(1)
106106
}
107-
log.info('Database migrations applied successfully')
108107
const queriesApplied = await applyDatabaseQueries(buildHubConfig, db)
109108
if (queriesApplied === false) {
110109
process.exit(1)
111110
}
112-
log.info('Database queries applied successfully')
113111
} catch (error: unknown) {
114112
log.error('Failed to apply database migrations during build:', error)
115113
throw error

0 commit comments

Comments
 (0)