docker fix
This commit is contained in:
@@ -27,7 +27,56 @@ sleep 5
|
||||
|
||||
# Run database migrations
|
||||
echo "🔄 Running database migrations..."
|
||||
node dist/database/migrateOnStartup.js
|
||||
|
||||
# Create migrations directory structure
|
||||
mkdir -p dist/database/migrations
|
||||
|
||||
# Copy any available migrations
|
||||
if [ -d "src/database/migrations" ]; then
|
||||
echo "<22> Found SQL migrations. Copying..."
|
||||
cp -R src/database/migrations/* dist/database/migrations/ 2>/dev/null || echo "No SQL migrations to copy"
|
||||
fi
|
||||
|
||||
# Copy JS migrations if available
|
||||
if [ -d "migrations" ]; then
|
||||
echo "📂 Found JS migrations. Copying..."
|
||||
mkdir -p migrations-temp
|
||||
cp migrations/*.js migrations-temp/ 2>/dev/null || echo "No JS migrations to copy"
|
||||
# Move JS migrations to dist/database/migrations
|
||||
cp migrations-temp/*.js dist/database/migrations/ 2>/dev/null || echo "No JS migrations to copy to dist"
|
||||
fi
|
||||
|
||||
# Display environment variables for debugging (without passwords)
|
||||
echo "🔍 Environment variables for database connection:"
|
||||
echo "DB_HOST: $DB_HOST"
|
||||
echo "DB_PORT: $DB_PORT"
|
||||
echo "DB_NAME: $DB_NAME"
|
||||
echo "DB_USERNAME: $DB_USERNAME"
|
||||
|
||||
# Run migrations using node-pg-migrate
|
||||
echo "🔄 Running migrations with node-pg-migrate..."
|
||||
DATABASE_URL="postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" npx node-pg-migrate up
|
||||
|
||||
# Verify connection to database
|
||||
echo "🔍 Verifying database connection..."
|
||||
node -e "
|
||||
const { Pool } = require('pg');
|
||||
const pool = new Pool({
|
||||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT,
|
||||
database: process.env.DB_NAME,
|
||||
user: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD
|
||||
});
|
||||
pool.query('SELECT NOW()', (err, res) => {
|
||||
if (err) {
|
||||
console.error('❌ Database connection failed:', err.message);
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log('✅ Database connection successful:', res.rows[0].now);
|
||||
pool.end();
|
||||
}
|
||||
});" || echo "❌ Failed to verify database connection"
|
||||
|
||||
# Start the bot
|
||||
echo "✅ Starting the bot..."
|
||||
|
||||
Reference in New Issue
Block a user