mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-11 17:26:45 +02:00
Update Dockerfile to generate database migrations, compile a migration script, and adjust the CMD for application startup. Modify docker-compose.yml to comment out PostgreSQL port exposure for security and update the command to run the new migration script. Add dependencies and a new migration script (server/migrate.ts) to handle database schema changes. Update INSTALLATION.md to reflect changes in database access and security recommendations. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/ds3R7vP
32 lines
836 B
TypeScript
32 lines
836 B
TypeScript
import { Pool } from 'pg';
|
|
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
import { migrate } from 'drizzle-orm/node-postgres/migrator';
|
|
import * as schema from '../shared/schema.js';
|
|
|
|
async function runMigrations() {
|
|
const connectionString = process.env.DATABASE_URL;
|
|
|
|
if (!connectionString) {
|
|
console.error('DATABASE_URL environment variable is not set');
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('Running database migrations...');
|
|
|
|
const pool = new Pool({ connectionString });
|
|
const db = drizzle(pool, { schema });
|
|
|
|
try {
|
|
await migrate(db, { migrationsFolder: './drizzle' });
|
|
console.log('Migrations completed successfully');
|
|
await pool.end();
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Migration failed:', error);
|
|
await pool.end();
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
runMigrations();
|