Fix init db script

This commit is contained in:
Justin Edmund 2025-06-10 02:29:35 -07:00
parent 18ee45799f
commit 828f66c2b4
2 changed files with 9 additions and 1 deletions

View file

@ -13,8 +13,9 @@ async function isDatabaseInitialized(): Promise<boolean> {
`
return migrationCount[0].count > 0n
} catch (error) {
} catch (error: any) {
// If the table doesn't exist, database is not initialized
console.log('📊 Migration table check failed (expected on first deploy):', error.message)
return false
}
}
@ -22,6 +23,9 @@ async function isDatabaseInitialized(): Promise<boolean> {
async function initializeDatabase() {
console.log('🔍 Checking database initialization status...')
// Give the database a moment to be ready
await new Promise(resolve => setTimeout(resolve, 2000))
try {
const isInitialized = await isDatabaseInitialized()

View file

@ -3,6 +3,10 @@
# Railway deployment script
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)
echo "🗄️ Initializing database..."
npm run db:init