mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-11 17:29:48 +02:00
Switch to local PostgreSQL configuration and improve data handling
Migrates from Neon serverless to local PostgreSQL, fixes timestamp comparisons, and applies Node.js 18 compatibility fixes. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 91318273-c764-4fd4-be04-bdc12c38af32 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/142044c4-d937-4abb-ae50-83d9764cfb4d.jpg
This commit is contained in:
1 parent
49e15b7e46
commit
1baefe2767
5 files changed
+274
-115
No files matched your search
@@ -18,7 +18,7 @@ export async function purgeSalesData() {
|
||||
// Supprimer les ventes antérieures à la date limite
|
||||
const result = await db
|
||||
.delete(sales)
|
||||
.where(lt(sales.timestamp, cutoffDate.toISOString()))
|
||||
.where(lt(sales.timestamp, cutoffDate))
|
||||
.returning({ id: sales.id });
|
||||
|
||||
const deletedCount = result.length;
|
||||
@@ -58,7 +58,7 @@ export async function getPurgeStats() {
|
||||
const oldSales = await db
|
||||
.select({ id: sales.id })
|
||||
.from(sales)
|
||||
.where(lt(sales.timestamp, cutoffDate.toISOString()));
|
||||
.where(lt(sales.timestamp, cutoffDate));
|
||||
|
||||
// Compter le total des ventes
|
||||
const totalSales = await db
|
||||
|
||||
+9
-7
@@ -1,15 +1,17 @@
|
||||
import { Pool, neonConfig } from '@neondatabase/serverless';
|
||||
import { drizzle } from 'drizzle-orm/neon-serverless';
|
||||
import ws from "ws";
|
||||
import { Pool } from 'pg';
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import * as schema from "@shared/schema";
|
||||
|
||||
neonConfig.webSocketConstructor = ws;
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
throw new Error(
|
||||
"DATABASE_URL must be set. Did you forget to provision a database?",
|
||||
);
|
||||
}
|
||||
|
||||
export const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
||||
export const db = drizzle({ client: pool, schema });
|
||||
export const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
// Configuration pour PostgreSQL local
|
||||
ssl: false
|
||||
});
|
||||
|
||||
export const db = drizzle(pool, { schema });
|
||||
Reference in new issue
Block a user