Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Srodif/create deleted at column #565

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export class UserEntity extends BaseBloomEntity {
@Column({ type: 'timestamptz', nullable: true })
lastActiveAt: Date; // set each time user record is fetched

@Column({ type: 'timestamptz', nullable: true })
deletedAt: Date; // set when the deleteUser method is called

@OneToMany(() => PartnerAccessEntity, (partnerAccess) => partnerAccess.user, { cascade: true })
partnerAccess: PartnerAccessEntity[];

Expand Down
14 changes: 14 additions & 0 deletions src/migrations/1722295564731-bloom-backend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class BloomBackend1722295564731 implements MigrationInterface {
name = 'BloomBackend1722295564731'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" ADD "deletedAt" TIMESTAMP WITH TIME ZONE`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "deletedAt"`);
}

}
1 change: 1 addition & 0 deletions src/partner-admin/partner-admin-auth.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { PartnerAdminAuthGuard } from './partner-admin-auth.guard';

const userEntity: UserEntity = {
updatedAt: null,
deletedAt: null,
createdAt: new Date(),
firebaseUid: '123',
id: 'userid',
Expand Down
2 changes: 2 additions & 0 deletions src/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { bloomBackend1706174260018 } from './migrations/1706174260018-bloom-back
import { BloomBackend1718300621138 } from './migrations/1718300621138-bloom-backend';
import { BloomBackend1718728423454 } from './migrations/1718728423454-bloom-backend';
import { BloomBackend1719668310816 } from './migrations/1719668310816-bloom-backend';
import { BloomBackend1722295564731 } from './migrations/1722295564731-bloom-backend';

config();
const configService = new ConfigService();
Expand Down Expand Up @@ -118,6 +119,7 @@ export const dataSourceOptions = {
BloomBackend1718300621138,
BloomBackend1718728423454,
BloomBackend1719668310816,
BloomBackend1722295564731,
],
subscribers: [],
ssl: isProduction || isStaging,
Expand Down
1 change: 1 addition & 0 deletions src/user/user.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface IUser {
id: string;
createdAt: Date | string;
updatedAt: Date | string;
deletedAt: Date | string;
firebaseUid?: string;
name: string;
email: string;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const formatUserObject = (userObject: UserEntity): GetUserDto => {
id: userObject.id,
createdAt: userObject.createdAt,
updatedAt: userObject.updatedAt,
deletedAt: userObject.deletedAt,
name: userObject.name,
email: userObject.email,
firebaseUid: userObject.firebaseUid,
Expand Down Expand Up @@ -125,6 +126,7 @@ export const formatGetUsersObject = (userObject: UserEntity): GetUserDto => {
id: userObject.id,
createdAt: userObject.createdAt,
updatedAt: userObject.updatedAt,
deletedAt: userObject.deletedAt,
name: userObject.name,
email: userObject.email,
firebaseUid: userObject.firebaseUid,
Expand Down
1 change: 1 addition & 0 deletions test/utils/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const mockUserEntity: UserEntity = {
lastActiveAt: new Date(),
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
partnerAccess: [],
partnerAdmin: null,
courseUser: [],
Expand Down
Loading