From ed9f86df0431878ce77eeba69b19acac36302e17 Mon Sep 17 00:00:00 2001 From: NotKevin <––25735164+NotKevin@users.noreply.github.com> Date: Mon, 22 Nov 2021 16:53:11 -0600 Subject: [PATCH] Added authorGithubId column to contributions table (based on PR #70) --- packages/api/src/entities/Contribution.ts | 7 ++++++- ...007-add-author-github-id-to-contribution-table.ts | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 packages/api/src/migrations/0007-add-author-github-id-to-contribution-table.ts diff --git a/packages/api/src/entities/Contribution.ts b/packages/api/src/entities/Contribution.ts index 8c53519..529738c 100644 --- a/packages/api/src/entities/Contribution.ts +++ b/packages/api/src/entities/Contribution.ts @@ -10,6 +10,9 @@ export class Contribution extends Node { @Property({ columnType: 'text' }) nodeID: string; + @Property({ columnType: 'text' }) + authorGithubId: string; + @Property({ columnType: 'text' }) description: string; @@ -21,13 +24,14 @@ export class Contribution extends Node { @Property({ columnType: 'timestamp' }) contributedAt: Date; - + constructor({ nodeID, description, type, score, contributedAt, + authorGithubId, ...extraValues }: ContributionConstructorValues) { super(extraValues); @@ -36,5 +40,6 @@ export class Contribution extends Node { this.type = type; this.score = score; this.contributedAt = contributedAt; + this.authorGithubId = authorGithubId; } } diff --git a/packages/api/src/migrations/0007-add-author-github-id-to-contribution-table.ts b/packages/api/src/migrations/0007-add-author-github-id-to-contribution-table.ts new file mode 100644 index 0000000..5d225f0 --- /dev/null +++ b/packages/api/src/migrations/0007-add-author-github-id-to-contribution-table.ts @@ -0,0 +1,12 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20211122225031 extends Migration { + + async up(): Promise { + this.addSql('alter table "contribution" add column "authorGithubId" text not null;'); + } + + async down(): Promise { + this.addSql('alter table "contribution" drop column "authorGithubId";'); + } +}