diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index c9e5ea79f..ee99ef809 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -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 diff --git a/backend/src/graphql/resolver/util/creations.ts b/backend/src/graphql/resolver/util/creations.ts index eb4b6394d..54286d2aa 100644 --- a/backend/src/graphql/resolver/util/creations.ts +++ b/backend/src/graphql/resolver/util/creations.ts @@ -103,6 +103,9 @@ export const getUserCreation = async ( const getCreationMonths = (timezoneOffset: number): number[] => { const clientNow = new Date() clientNow.setTime(clientNow.getTime() - timezoneOffset * 60 * 1000) + logger.info( + `getCreationMonths -- offset: ${timezoneOffset} -- clientNow: ${clientNow.toISOString()}`, + ) return [ new Date(clientNow.getFullYear(), clientNow.getMonth() - 2, 1).getMonth() + 1, new Date(clientNow.getFullYear(), clientNow.getMonth() - 1, 1).getMonth() + 1, diff --git a/database/migrations/0055-consistent_deleted_users.ts b/database/migrations/0055-consistent_deleted_users.ts new file mode 100644 index 000000000..561e0541a --- /dev/null +++ b/database/migrations/0055-consistent_deleted_users.ts @@ -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>) { + 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>) {}