Fix init db script
This commit is contained in:
parent
18ee45799f
commit
828f66c2b4
2 changed files with 9 additions and 1 deletions
|
|
@ -13,8 +13,9 @@ async function isDatabaseInitialized(): Promise<boolean> {
|
||||||
`
|
`
|
||||||
|
|
||||||
return migrationCount[0].count > 0n
|
return migrationCount[0].count > 0n
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
// If the table doesn't exist, database is not initialized
|
// If the table doesn't exist, database is not initialized
|
||||||
|
console.log('📊 Migration table check failed (expected on first deploy):', error.message)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -22,6 +23,9 @@ async function isDatabaseInitialized(): Promise<boolean> {
|
||||||
async function initializeDatabase() {
|
async function initializeDatabase() {
|
||||||
console.log('🔍 Checking database initialization status...')
|
console.log('🔍 Checking database initialization status...')
|
||||||
|
|
||||||
|
// Give the database a moment to be ready
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isInitialized = await isDatabaseInitialized()
|
const isInitialized = await isDatabaseInitialized()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
# Railway deployment script
|
# Railway deployment script
|
||||||
echo "🚂 Starting Railway deployment..."
|
echo "🚂 Starting Railway deployment..."
|
||||||
|
|
||||||
|
# Generate Prisma client first
|
||||||
|
echo "📦 Generating Prisma client..."
|
||||||
|
npx prisma generate
|
||||||
|
|
||||||
# Initialize database (runs migrations and seeds on first deploy only)
|
# Initialize database (runs migrations and seeds on first deploy only)
|
||||||
echo "🗄️ Initializing database..."
|
echo "🗄️ Initializing database..."
|
||||||
npm run db:init
|
npm run db:init
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue