Browse Source

Fix cyclic dependency issues in DB

ghorsington 5 years ago
parent
commit
aa6cda84a3
3 changed files with 12 additions and 6 deletions
  1. 4 2
      db/src/entity/Contest.ts
  2. 4 2
      db/src/entity/ContestEntry.ts
  3. 4 2
      db/src/entity/ContestVote.ts

+ 4 - 2
db/src/entity/Contest.ts

@@ -32,9 +32,11 @@ export class Contest {
     @Column({ default: false })
     active: boolean;
 
-    @OneToMany(type => ContestEntry, entry => entry.contest)
+    // @OneToMany(type => ContestEntry, entry => entry.contest)
+    @OneToMany("ContestEntry", "contest")
     entries: ContestEntry[];
 
-    @OneToMany(type => ContestVote, vote => vote.contest)
+    // @OneToMany(type => ContestVote, vote => vote.contest)
+    @OneToMany("ContestVote", "contest")
     votes: ContestVote[];
 }

+ 4 - 2
db/src/entity/ContestEntry.ts

@@ -8,9 +8,11 @@ export class ContestEntry {
     @PrimaryColumn()
     msgId: string;
 
-    @ManyToOne(type => Contest, contest => contest.entries)
+    // @ManyToOne(type => Contest, contest => contest.entries)
+    @ManyToOne("Contest", "entries")
     contest: Contest;
 
-    @OneToMany(type => ContestVote, vote => vote.contestEntry)
+    // @OneToMany(type => ContestVote, vote => vote.contestEntry)
+    @OneToMany("ContestVote", "contestEntry")
     votes: ContestVote[];
 }

+ 4 - 2
db/src/entity/ContestVote.ts

@@ -11,9 +11,11 @@ export class ContestVote {
     @PrimaryColumn()
     contestId: number;
 
-    @ManyToOne(type => Contest, contest => contest.votes, { primary: true })
+    // @ManyToOne(type => Contest, contest => contest.votes, { primary: true })
+    @ManyToOne("Contest", "votes", { primary: true })
     contest: Contest;
 
-    @ManyToOne(type => ContestEntry, entry => entry.votes)
+    // @ManyToOne(type => ContestEntry, entry => entry.votes)
+    @ManyToOne("ContestEntry", "votes")
     contestEntry: ContestEntry;
 }