
- Updated package.json to use PostgreSQL dependencies (pg, @types/pg)
- Removed SQLite dependency
- Updated TypeORM configuration for PostgreSQL connection
- Modified database entities to use PostgreSQL-compatible column types (jsonb, timestamp)
- Created comprehensive database migration script for initial schema
- Updated environment configuration with PostgreSQL variables
- Updated README with PostgreSQL setup instructions and database migration steps
- Ensured storage directories are properly configured
🤖 Generated with BackendIM
Co-Authored-By: Claude <noreply@anthropic.com>
21 lines
863 B
TypeScript
21 lines
863 B
TypeScript
import { DataSource } from 'typeorm';
|
|
import { ConfigService } from '@nestjs/config';
|
|
import { config } from 'dotenv';
|
|
|
|
config();
|
|
|
|
const configService = new ConfigService();
|
|
|
|
export default new DataSource({
|
|
type: 'postgres',
|
|
host: configService.get<string>('DB_HOST') || 'localhost',
|
|
port: configService.get<number>('DB_PORT') || 5432,
|
|
username: configService.get<string>('DB_USERNAME') || 'postgres',
|
|
password: configService.get<string>('DB_PASSWORD') || 'postgres',
|
|
database: configService.get<string>('DB_NAME') || 'realtime_chat_db',
|
|
entities: [__dirname + '/entities/**/*.entity{.ts,.js}'],
|
|
migrations: [__dirname + '/migrations/**/*{.ts,.js}'],
|
|
synchronize: false,
|
|
logging: configService.get<string>('NODE_ENV') === 'development',
|
|
ssl: configService.get<string>('NODE_ENV') === 'production' ? { rejectUnauthorized: false } : false,
|
|
}); |