Merge pull request #2451 from gradido/consistent-user-contacts-table

fix(database): consistent deleted at bewteen users and user contacts
This commit is contained in:
Moriz Wahl 2022-12-12 14:58:51 +01:00 committed by GitHub
commit 907cd03ab8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -10,7 +10,7 @@ Decimal.set({
})
const constants = {
DB_VERSION: '0054-recalculate_balance_and_decay',
DB_VERSION: '0055-consistent_deleted_users',
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
LOG4JS_CONFIG: 'log4js-config.json',
// default log level on production should be info

View File

@ -0,0 +1,16 @@
/* MIGRATION TO soft delete user contacts of soft deleted users */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
await queryFn(`
UPDATE user_contacts LEFT JOIN users ON users.email_id = user_contacts.id
SET user_contacts.deleted_at = users.deleted_at
WHERE user_contacts.deleted_at IS NULL
AND users.deleted_at IS NOT NULL;`)
}
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {}