mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-21 05:58:23 +02:00
Ensure PostgreSQL tables are created and data is migrated
This commit modifies the database connection logic to prioritize PostgreSQL, introduces a new PostgreSQL initialization script with table creation and test data, and refactors announcement storage to use a global instance. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/e437ffed-c31b-44eb-9fd5-b6f9faa8e7ce/zIqUatC
This commit is contained in:
1 parent
a3889dd088
commit
b1ea9dcc9b
4 files changed
+47
-39
No files matched your search
@@ -103,6 +103,7 @@ class AnnouncementMemoryStorage {
|
||||
const announcement: Announcement = {
|
||||
id,
|
||||
...announcementData,
|
||||
priority: announcementData.priority || 'normal',
|
||||
groupId: announcementData.groupId || null,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
@@ -178,27 +179,18 @@ class AnnouncementMemoryStorage {
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
// Méthode utilitaire pour obtenir le nombre d'annonces
|
||||
getCount(): number {
|
||||
return this.announcements.size;
|
||||
}
|
||||
|
||||
// Méthode utilitaire pour nettoyer toutes les annonces (si nécessaire)
|
||||
clear(): void {
|
||||
this.announcements.clear();
|
||||
this.idCounter = 1;
|
||||
console.log('🧹 Toutes les annonces ont été supprimées');
|
||||
}
|
||||
}
|
||||
|
||||
// Instance singleton pour partager entre production et développement
|
||||
let announcementStorage: AnnouncementMemoryStorage | null = null;
|
||||
// Instance globale partagée
|
||||
let globalAnnouncementStorage: AnnouncementMemoryStorage | null = null;
|
||||
|
||||
export function getAnnouncementStorage(usersGetter: () => Promise<User[]>, groupsGetter: () => Promise<Group[]>): AnnouncementMemoryStorage {
|
||||
if (!announcementStorage) {
|
||||
announcementStorage = new AnnouncementMemoryStorage(usersGetter, groupsGetter);
|
||||
console.log('📢 Système d\'annonces en mémoire initialisé (max 5 annonces)');
|
||||
export function getAnnouncementStorage(
|
||||
usersGetter: () => Promise<User[]>,
|
||||
groupsGetter: () => Promise<Group[]>
|
||||
): AnnouncementMemoryStorage {
|
||||
if (!globalAnnouncementStorage) {
|
||||
globalAnnouncementStorage = new AnnouncementMemoryStorage(usersGetter, groupsGetter);
|
||||
console.log('📢 Stockage mémoire des annonces initialisé');
|
||||
}
|
||||
return announcementStorage;
|
||||
return globalAnnouncementStorage;
|
||||
}
|
||||
Reference in new issue
Block a user