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

Fix Discord & Google Calendar UUIDs #439

Merged
merged 6 commits into from
May 7, 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
12 changes: 12 additions & 0 deletions migrations/0045-fix-discord-gcal-field.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class FixDiscordGcalField1714770061929 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
// nothing here because it's fixing an earlier migration (# 0044)
dowhep marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 2 additions & 2 deletions models/EventModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ export class EventModel extends BaseEntity {
@OneToMany((type) => ExpressCheckinModel, (expressCheckin) => expressCheckin.event, { cascade: true })
expressCheckins: ExpressCheckinModel[];

@Column('uuid', { nullable: true })
@Column('varchar', { nullable: true })
discordEvent: Uuid;

@Column('uuid', { nullable: true })
@Column('varchar', { nullable: true })
googleCalendarEvent: Uuid;

public getPublicEvent(canSeeAttendanceCode = false): PublicEvent {
Expand Down
4 changes: 2 additions & 2 deletions tests/data/EventFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the way discord generate Uuid or is this just random string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a random string. Discord UUIDs are different (see this error message: https://discord.com/channels/573028991527550986/1012204566122598431/1236042800043397261) than what Postgres allows for UUIDs (https://www.postgresql.org/docs/current/datatype-uuid.html), which is why I opted to make it a string

googleCalendarEvent: faker.datatype.hexaDecimal(10),
});
return EventModel.merge(fake, substitute);
}
Expand Down
Loading