feat(database): add logger to database migration

This commit is contained in:
Lars Hampe 2024-10-02 15:24:13 +02:00
parent 537acd5658
commit 30b0a1c584
2 changed files with 5 additions and 3 deletions

View File

@ -18,6 +18,7 @@
"typescript": "^5.0.0"
},
"dependencies": {
"@boring.tools/logger": "workspace:*",
"drizzle-orm": "^0.33.0",
"pg": "^8.13.0"
}

View File

@ -1,3 +1,4 @@
import { logger } from '@boring.tools/logger'
import { migrate } from 'drizzle-orm/postgres-js/migrator'
import { client, db } from './'
@ -5,9 +6,9 @@ export const migrateDatabase = async (dir: string) => {
try {
await migrate(db, { migrationsFolder: dir })
await client.end()
console.log('Migrations: Ok')
logger.log('Migrations: Ok')
} catch (error) {
console.error('Migrations: Failed')
console.error(error)
logger.error('Migrations: Failed')
logger.error(error)
}
}