From 049c9c67d2b783c61482ebf341fff966cbf76b37 Mon Sep 17 00:00:00 2001 From: Nikhil Dange Date: Fri, 3 May 2024 13:24:30 -0700 Subject: [PATCH 1/5] fixed UUIDs --- api/validators/EventControllerRequests.ts | 4 ++-- models/EventModel.ts | 8 ++++---- types/ApiRequests.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/validators/EventControllerRequests.ts b/api/validators/EventControllerRequests.ts index 1a8a1306..0b55bc4f 100644 --- a/api/validators/EventControllerRequests.ts +++ b/api/validators/EventControllerRequests.ts @@ -31,10 +31,10 @@ export class OptionalEventProperties implements IOptionalEventProperties { staffPointBonus?: number; @Allow() - discordEvent?: Uuid; + discordEvent?: string; @Allow() - googleCalendarEvent?: Uuid; + googleCalendarEvent?: string; } export class Event extends OptionalEventProperties implements IEvent { diff --git a/models/EventModel.ts b/models/EventModel.ts index 0fae36f5..e2820535 100644 --- a/models/EventModel.ts +++ b/models/EventModel.ts @@ -67,11 +67,11 @@ export class EventModel extends BaseEntity { @OneToMany((type) => ExpressCheckinModel, (expressCheckin) => expressCheckin.event, { cascade: true }) expressCheckins: ExpressCheckinModel[]; - @Column('uuid', { nullable: true }) - discordEvent: Uuid; + @Column('varchar', { nullable: true }) + discordEvent: string; - @Column('uuid', { nullable: true }) - googleCalendarEvent: Uuid; + @Column('varchar', { nullable: true }) + googleCalendarEvent: string; public getPublicEvent(canSeeAttendanceCode = false): PublicEvent { const publicEvent: PublicEvent = { diff --git a/types/ApiRequests.ts b/types/ApiRequests.ts index 816b59f7..7d163efe 100644 --- a/types/ApiRequests.ts +++ b/types/ApiRequests.ts @@ -155,8 +155,8 @@ export interface OptionalEventProperties { eventLink?: string; requiresStaff?: boolean; staffPointBonus?: number; - discordEvent?: Uuid; - googleCalendarEvent?: Uuid; + discordEvent?: string; + googleCalendarEvent?: string; } export interface Event extends OptionalEventProperties { From d410029a68bae4a1c528e75419be7759e95b0b0b Mon Sep 17 00:00:00 2001 From: Nikhil Dange Date: Fri, 3 May 2024 13:25:59 -0700 Subject: [PATCH 2/5] fixed test --- tests/data/EventFactory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/EventFactory.ts b/tests/data/EventFactory.ts index cefd6d14..6a71030d 100644 --- a/tests/data/EventFactory.ts +++ b/tests/data/EventFactory.ts @@ -41,8 +41,8 @@ export class EventFactory { deleted: false, eventLink: faker.internet.url(), thumbnail: FactoryUtils.getRandomImageUrl(), - discordEvent: uuid(), - googleCalendarEvent: uuid(), + discordEvent: faker.datatype.hexaDecimal(10) , + googleCalendarEvent: faker.datatype.hexaDecimal(10), }); return EventModel.merge(fake, substitute); } From 52bdeefc07186ab7e41fc635317f2f874ef1feca Mon Sep 17 00:00:00 2001 From: Nikhil Dange Date: Fri, 3 May 2024 14:28:24 -0700 Subject: [PATCH 3/5] a migration to fix the migration --- migrations/0045-fix-discord-gcal-field.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 migrations/0045-fix-discord-gcal-field.ts diff --git a/migrations/0045-fix-discord-gcal-field.ts b/migrations/0045-fix-discord-gcal-field.ts new file mode 100644 index 00000000..b561020c --- /dev/null +++ b/migrations/0045-fix-discord-gcal-field.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; + +export class FixDiscordGcalField1714770061929 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query('ALTER TABLE "Events" ALTER COLUMN "discordEvent" TYPE varchar'); + await queryRunner.query('ALTER TABLE "Events" ALTER COLUMN "googleCalendarEvent" TYPE varchar'); + } + + public async down(queryRunner: QueryRunner): Promise { + // nothing here because it's fixing an earlier migration (# 0044) + } + +} From 4f09e4a5395df69fd13ad5c8e786a038a7907daf Mon Sep 17 00:00:00 2001 From: Nikhil Dange Date: Fri, 3 May 2024 14:32:35 -0700 Subject: [PATCH 4/5] linting --- api/validators/EventControllerRequests.ts | 1 - migrations/0045-fix-discord-gcal-field.ts | 20 +++++++++----------- tests/data/EventFactory.ts | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/api/validators/EventControllerRequests.ts b/api/validators/EventControllerRequests.ts index 0b55bc4f..7f35f3b3 100644 --- a/api/validators/EventControllerRequests.ts +++ b/api/validators/EventControllerRequests.ts @@ -7,7 +7,6 @@ import { PatchEventRequest as IPatchEventRequest, SubmitEventFeedbackRequest as ISubmitEventFeedbackRequest, Event as IEvent, - Uuid, } from '../../types'; import { IsValidEventFeedback } from '../decorators/Validators'; diff --git a/migrations/0045-fix-discord-gcal-field.ts b/migrations/0045-fix-discord-gcal-field.ts index b561020c..5cb62f6d 100644 --- a/migrations/0045-fix-discord-gcal-field.ts +++ b/migrations/0045-fix-discord-gcal-field.ts @@ -1,14 +1,12 @@ -import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; +import { MigrationInterface, QueryRunner } from 'typeorm'; export class FixDiscordGcalField1714770061929 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query('ALTER TABLE "Events" ALTER COLUMN "discordEvent" TYPE varchar'); - await queryRunner.query('ALTER TABLE "Events" ALTER COLUMN "googleCalendarEvent" TYPE varchar'); - } - - public async down(queryRunner: QueryRunner): Promise { - // nothing here because it's fixing an earlier migration (# 0044) - } - + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query('ALTER TABLE "Events" ALTER COLUMN "discordEvent" TYPE varchar'); + await queryRunner.query('ALTER TABLE "Events" ALTER COLUMN "googleCalendarEvent" TYPE varchar'); + } + + public async down(queryRunner: QueryRunner): Promise { + // nothing here because it's fixing an earlier migration (# 0044) + } } diff --git a/tests/data/EventFactory.ts b/tests/data/EventFactory.ts index 6a71030d..bf6a9d38 100644 --- a/tests/data/EventFactory.ts +++ b/tests/data/EventFactory.ts @@ -41,7 +41,7 @@ export class EventFactory { deleted: false, eventLink: faker.internet.url(), thumbnail: FactoryUtils.getRandomImageUrl(), - discordEvent: faker.datatype.hexaDecimal(10) , + discordEvent: faker.datatype.hexaDecimal(10), googleCalendarEvent: faker.datatype.hexaDecimal(10), }); return EventModel.merge(fake, substitute); From d88c98e01325918ec2c562bc61e22f2a1ead437d Mon Sep 17 00:00:00 2001 From: Nikhil Dange Date: Tue, 7 May 2024 15:49:06 -0700 Subject: [PATCH 5/5] updated uuid type --- api/validators/EventControllerRequests.ts | 5 +++-- models/EventModel.ts | 4 ++-- types/ApiRequests.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/api/validators/EventControllerRequests.ts b/api/validators/EventControllerRequests.ts index 7f35f3b3..1a8a1306 100644 --- a/api/validators/EventControllerRequests.ts +++ b/api/validators/EventControllerRequests.ts @@ -7,6 +7,7 @@ import { PatchEventRequest as IPatchEventRequest, SubmitEventFeedbackRequest as ISubmitEventFeedbackRequest, Event as IEvent, + Uuid, } from '../../types'; import { IsValidEventFeedback } from '../decorators/Validators'; @@ -30,10 +31,10 @@ export class OptionalEventProperties implements IOptionalEventProperties { staffPointBonus?: number; @Allow() - discordEvent?: string; + discordEvent?: Uuid; @Allow() - googleCalendarEvent?: string; + googleCalendarEvent?: Uuid; } export class Event extends OptionalEventProperties implements IEvent { diff --git a/models/EventModel.ts b/models/EventModel.ts index e2820535..256fa443 100644 --- a/models/EventModel.ts +++ b/models/EventModel.ts @@ -68,10 +68,10 @@ export class EventModel extends BaseEntity { expressCheckins: ExpressCheckinModel[]; @Column('varchar', { nullable: true }) - discordEvent: string; + discordEvent: Uuid; @Column('varchar', { nullable: true }) - googleCalendarEvent: string; + googleCalendarEvent: Uuid; public getPublicEvent(canSeeAttendanceCode = false): PublicEvent { const publicEvent: PublicEvent = { diff --git a/types/ApiRequests.ts b/types/ApiRequests.ts index 7d163efe..816b59f7 100644 --- a/types/ApiRequests.ts +++ b/types/ApiRequests.ts @@ -155,8 +155,8 @@ export interface OptionalEventProperties { eventLink?: string; requiresStaff?: boolean; staffPointBonus?: number; - discordEvent?: string; - googleCalendarEvent?: string; + discordEvent?: Uuid; + googleCalendarEvent?: Uuid; } export interface Event extends OptionalEventProperties {