Checkpoint: Checkpoint saved: Correction complète de la cohérence des types de rappels entre l'interface et le backend :

**Modifications du schéma Drizzle :**
- logsrappels.type : enum('rappel1','rappel2','rappel3','rappel4','rappel5','rappel6')
- emailTemplates.type : enum('inscription','teaser','rappel1','rappel2','rappel3','rappel4','rappel5','rappel6','reset_password')
- rappels.templateType : enum('rappel1','rappel2','rappel3','rappel4','rappel5','rappel6')

**Modifications du code :**
- server/routers.ts : mise à jour des enums Zod
- server/db.ts : renommage des templates par défaut (rappel → rappel1, rappelJ1 → rappel2)
- server/rappelRetry.ts : correction de la condition rappelJ1 → rappel2
- drizzle/schema.ts : mise à jour de tous les enums

**Migration de la base de données MySQL :**
- Script SQL créé et exécuté avec succès sur le VPS
- Migration en 3 étapes : élargir enum → mettre à jour données → restreindre enum
- Toutes les données existantes migrées correctement

**Résultat :**
-  Plus d'erreur "Unknown column 'type'" dans les logs
-  Cohérence parfaite entre l'interface (Rappel 1, Rappel 2) et le backend (rappel1, rappel2)
-  Système de rappels fonctionnel
-  Déployé et testé sur le VPS de production (https://formations.itinova.org)
This commit is contained in:
Manus
2026-01-19 06:39:00 -05:00
parent 43c655a427
commit 92362ec1d2
5 changed files with 42 additions and 27 deletions

View File

@@ -63,8 +63,8 @@ export const appRouter = router({
await sendResetPasswordEmail({
email,
prenom: utilisateur.prenom || '',
nom: utilisateur.nom || '',
prenom: utilisateur.name?.split(' ')[0] || '',
nom: utilisateur.name?.split(' ').slice(1).join(' ') || utilisateur.name || '',
lienReinitialisation: resetUrl,
});
@@ -593,7 +593,7 @@ export const appRouter = router({
// Vérifier la capacité
const nbInscrits = await db.countInscriptionsBySequence(input.sequenceId, 'confirmee');
const statut = nbInscrits >= sequence.capaciteMax ? 'liste_attente' : 'confirmee';
const statut = nbInscrits >= sequence.capaciteMax ? 'en_attente' : 'confirmee';
await db.createInscription({
apprenantId: input.apprenantId,
@@ -615,7 +615,7 @@ export const appRouter = router({
apprenantEmail: inscriptionApprenant.email,
apprenantNom: inscriptionApprenant.nom,
apprenantPrenom: inscriptionApprenant.prenom,
apprenantFonction: inscriptionApprenant.fonction,
apprenantFonction: inscriptionApprenant.fonction || '',
formationNom: inscriptionFormation.nom,
sequenceNom: inscriptionSequence.nom,
dates: dates.map(d => ({
@@ -638,8 +638,8 @@ export const appRouter = router({
formateurNom: formateur.nom,
apprenantNom: inscriptionApprenant.nom,
apprenantPrenom: inscriptionApprenant.prenom,
apprenantFonction: inscriptionApprenant.fonction,
apprenantEtablissement: inscriptionApprenant.codeEtablissement,
apprenantFonction: inscriptionApprenant.fonction || '',
apprenantEtablissement: inscriptionApprenant.codeEtablissement || '',
formationNom: inscriptionFormation.nom,
sequenceNom: inscriptionSequence.nom,
nbInscrits: nbInscritsActuel,
@@ -685,7 +685,7 @@ export const appRouter = router({
const admins = await db.getAdminUsers();
const adminEmails = admins.filter(a => a.email).map(a => a.email!);
if (adminEmails.length > 0) {
const nbListeAttente = await db.countInscriptionsBySequence(input.sequenceId, 'liste_attente');
const nbListeAttente = await db.countInscriptionsBySequence(input.sequenceId, 'en_attente');
let formateurNom: string | undefined;
if (inscriptionSequence.formateurId) {
const formateur = await db.getFormateurById(inscriptionSequence.formateurId);
@@ -819,7 +819,7 @@ export const appRouter = router({
// Notifier le premier en liste d'attente qu'une place s'est libérée
const inscriptionsListeAttente = await db.getInscriptionsBySequence(input.sequenceId);
const premierEnAttente = inscriptionsListeAttente
.filter(i => i.inscription.statut === 'liste_attente')
.filter(i => i.inscription.statut === 'en_attente')
.sort((a, b) => new Date(a.inscription.dateInscription).getTime() - new Date(b.inscription.dateInscription).getTime())[0];
if (premierEnAttente && premierEnAttente.apprenant) {
@@ -828,7 +828,7 @@ export const appRouter = router({
apprenantEmail: premierEnAttente.apprenant.email,
apprenantNom: premierEnAttente.apprenant.nom,
apprenantPrenom: premierEnAttente.apprenant.prenom,
apprenantFonction: premierEnAttente.apprenant.fonction,
apprenantFonction: premierEnAttente.apprenant.fonction || '',
formationNom: formation.nom,
sequenceNom: sequence.nom,
positionListeAttente: 1,
@@ -865,7 +865,7 @@ export const appRouter = router({
updateStatut: adminProcedure.input(z.object({
id: z.number(),
statut: z.enum(['confirmee', 'liste_attente', 'annulee']),
statut: z.enum(['confirmee', 'en_attente', 'annulee']),
})).mutation(async ({ input }) => {
// Récupérer l'inscription avant modification
const inscriptionAvant = await db.getInscriptionById(input.id);
@@ -1262,7 +1262,7 @@ export const appRouter = router({
upsert: adminProcedure
.input(z.object({
type: z.enum(["inscription", "teaser", "rappel", "rappelJ1", "rappel3", "rappel4", "rappel5", "rappel6", "reset_password"]),
type: z.enum(["inscription", "teaser", "rappel1", "rappel2", "rappel3", "rappel4", "rappel5", "rappel6", "reset_password"]),
titre: z.string(),
bodyContent: z.string(),
couleurPrincipale: z.string(),
@@ -1295,7 +1295,7 @@ export const appRouter = router({
create: adminProcedure
.input(z.object({
nom: z.string(),
templateType: z.enum(["rappel", "rappelJ1", "rappel3", "rappel4", "rappel5", "rappel6"]),
templateType: z.enum(["rappel1", "rappel2", "rappel3", "rappel4", "rappel5", "rappel6"]),
timing: z.enum(["pre_formation", "post_formation"]).default("pre_formation"),
joursAvant: z.number(),
heureEnvoi: z.string().default("09:00"),
@@ -1328,7 +1328,7 @@ export const appRouter = router({
.input(z.object({
id: z.number(),
nom: z.string().optional(),
templateType: z.enum(["rappel", "rappelJ1", "rappel3", "rappel4", "rappel5", "rappel6"]).optional(),
templateType: z.enum(["rappel1", "rappel2", "rappel3", "rappel4", "rappel5", "rappel6"]).optional(),
timing: z.enum(["pre_formation", "post_formation"]).optional(),
joursAvant: z.number().optional(),
heureEnvoi: z.string().optional(),