From 37ef2acf3e2a84d5e698920b80feb72636d1efc2 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 25 May 2020 19:03:58 +0200 Subject: [PATCH] Migration is working --- src/migrations/AccountImageMigration.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/migrations/AccountImageMigration.ts b/src/migrations/AccountImageMigration.ts index 14ffd31..c0df6ec 100644 --- a/src/migrations/AccountImageMigration.ts +++ b/src/migrations/AccountImageMigration.ts @@ -15,6 +15,8 @@ import { pathUserData } from "../utils/UserDataUtils"; import { readdirSync, readFileSync } from "fs"; import { AccountImageVisibilityLevel } from "../entities/User"; +import { DatabaseHelper } from "../helpers/DatabaseHelper"; +import { USER_TABLE } from "../helpers/AccountHelper"; const AVATARS_PATH = "avatars/"; const AVATARS_ADDRESSES_FILES = "avatars/adresse_avatars/"; @@ -51,6 +53,16 @@ export async function accountImageMigration() { const newPath = AVATARS_PATH + fileContent; console.info("User " + userID + "\tAccount image: " + newPath); + + await DatabaseHelper.UpdateRows({ + table: USER_TABLE, + where: { + ID: userID + }, + set: { + account_image_path: newPath + } + }) } // Account image visibility @@ -58,6 +70,17 @@ export async function accountImageMigration() { const newVisibililty = VisibilityLevelsMap[Number(fileContent)]; console.info("User " + userID + "\tVisibility: " + newVisibililty); + + + await DatabaseHelper.UpdateRows({ + table: USER_TABLE, + where: { + ID: userID + }, + set: { + account_image_visibility: newVisibililty + } + }) } } } \ No newline at end of file