Checkpoint: V1.24 - Correction erreur SQL upload attestations
Suppression des colonnes obsolètes (signatureUrl, signatureS3Key, dateSigned) de la table attestations qui causaient une erreur SQL lors de l'upload de documents. La procédure uploadSignature obsolète a également été supprimée du code. Déployé et testé sur TEST et PROD.
This commit is contained in:
9
.manus/db/db-query-1772187650360.json
Normal file
9
.manus/db/db-query-1772187650360.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"query": "ALTER TABLE attestations DROP COLUMN IF EXISTS signatureUrl, DROP COLUMN IF EXISTS signatureS3Key, DROP COLUMN IF EXISTS dateSigned;",
|
||||
"command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute ALTER TABLE attestations DROP COLUMN IF EXISTS signatureUrl, DROP COLUMN IF EXISTS signatureS3Key, DROP COLUMN IF EXISTS dateSigned;",
|
||||
"rows": [],
|
||||
"messages": [],
|
||||
"stdout": "",
|
||||
"stderr": "",
|
||||
"execution_time_ms": 1059
|
||||
}
|
||||
2292
drizzle/meta/0019_snapshot.json
Normal file
2292
drizzle/meta/0019_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -134,6 +134,13 @@
|
||||
"when": 1770388245873,
|
||||
"tag": "0018_adorable_northstar",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 19,
|
||||
"version": "5",
|
||||
"when": 1772187475069,
|
||||
"tag": "0019_aberrant_black_tarantula",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -462,12 +462,6 @@ export const attestations = mysqlTable("attestations", {
|
||||
emailEnvoye: boolean("emailEnvoye").default(false).notNull(),
|
||||
/** Date d'envoi de l'email */
|
||||
dateEnvoiEmail: timestamp("dateEnvoiEmail"),
|
||||
/** URL de la signature manuscrite */
|
||||
signatureUrl: varchar("signatureUrl", { length: 500 }),
|
||||
/** Clé S3 de la signature manuscrite */
|
||||
signatureS3Key: varchar("signatureS3Key", { length: 500 }),
|
||||
/** Date de signature */
|
||||
dateSigned: timestamp("dateSigned"),
|
||||
dateGeneration: timestamp("dateGeneration").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
|
||||
@@ -2486,46 +2486,7 @@ export const appRouter = router({
|
||||
return genererPreviewAttestation();
|
||||
}),
|
||||
|
||||
// Uploader la signature manuscrite d'un apprenant
|
||||
uploadSignature: publicProcedure
|
||||
.input(z.object({
|
||||
attestationId: z.number(),
|
||||
signatureDataUrl: z.string(),
|
||||
}))
|
||||
.mutation(async ({ input }) => {
|
||||
const { storagePut } = await import("./storage");
|
||||
const { getDb } = await import("./db");
|
||||
const { attestations } = await import("../drizzle/schema");
|
||||
const { eq } = await import("drizzle-orm");
|
||||
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("Base de données non disponible");
|
||||
|
||||
// Convertir le data URL en buffer
|
||||
const base64Data = input.signatureDataUrl.replace(/^data:image\/png;base64,/, "");
|
||||
const buffer = Buffer.from(base64Data, "base64");
|
||||
|
||||
// Générer un nom de fichier unique
|
||||
const fileName = `signatures/attestation-${input.attestationId}-${Date.now()}.png`;
|
||||
|
||||
// Uploader vers S3
|
||||
const { url, key } = await storagePut(fileName, buffer, "image/png");
|
||||
|
||||
// Mettre à jour l'attestation dans la base de données
|
||||
await db
|
||||
.update(attestations)
|
||||
.set({
|
||||
signatureUrl: url,
|
||||
signatureS3Key: key,
|
||||
dateSigned: new Date(),
|
||||
})
|
||||
.where(eq(attestations.id, input.attestationId));
|
||||
|
||||
return {
|
||||
success: true,
|
||||
signatureUrl: url,
|
||||
};
|
||||
}),
|
||||
}),
|
||||
|
||||
// ===== PRESENCES (ÉMARGEMENT NUMÉRIQUE) =====
|
||||
|
||||
8
todo.md
8
todo.md
@@ -1693,3 +1693,11 @@
|
||||
- [x] Ajouter un champ de recherche/filtre sur le nom, prénom et email
|
||||
- [x] Tester sur TEST
|
||||
- [x] Déployer sur PROD
|
||||
|
||||
## BUG - Erreur SQL lors de l'upload d'attestations
|
||||
|
||||
- [x] Diagnostiquer l'erreur "Failed query: insert into attestations" avec valeurs default (colonnes signature obsolètes)
|
||||
- [x] Supprimer les colonnes signatureUrl, signatureS3Key, dateSigned de la table attestations
|
||||
- [x] Supprimer la procédure uploadSignature obsolète dans routers.ts
|
||||
- [x] Tester sur TEST
|
||||
- [x] Déployer sur PROD
|
||||
|
||||
Reference in New Issue
Block a user