feat: configure postgresql as primary database with neon connection

- Updated .env to use PostgreSQL (neondb) instead of SQLite
- Updated drizzle.ts to support DATABASE_URL connection string
- Regenerated migrations for PostgreSQL syntax
- Bot successfully connects and operates with PostgreSQL
- All database operations working correctly
This commit is contained in:
MythEclipse
2026-05-14 16:25:39 +07:00
parent c63a61460c
commit 35269b5bef
7 changed files with 332 additions and 213 deletions
+20 -9
View File
@@ -24,15 +24,26 @@ export async function initializeDatabase() {
}
if (config.DATABASE_TYPE === "postgres") {
const pool = new Pool({
host: config.POSTGRES_HOST,
port: config.POSTGRES_PORT,
user: config.POSTGRES_USER,
password: config.POSTGRES_PASSWORD,
database: config.POSTGRES_DB,
min: config.POSTGRES_POOL_MIN,
max: config.POSTGRES_POOL_MAX,
});
let pool: Pool;
// Use DATABASE_URL if available, otherwise build from individual variables
if (config.DATABASE_URL) {
pool = new Pool({
connectionString: config.DATABASE_URL,
min: config.POSTGRES_POOL_MIN,
max: config.POSTGRES_POOL_MAX,
});
} else {
pool = new Pool({
host: config.POSTGRES_HOST,
port: config.POSTGRES_PORT,
user: config.POSTGRES_USER,
password: config.POSTGRES_PASSWORD,
database: config.POSTGRES_DB,
min: config.POSTGRES_POOL_MIN,
max: config.POSTGRES_POOL_MAX,
});
}
db = drizzlePostgres(pool, { schema });
logger.info("PostgreSQL database initialized");