From bb4e64f957f65cbf6944dd20b7c567c6f2d7fc1c Mon Sep 17 00:00:00 2001
From: Ronnie Friman <L4168@student.jamk.fi>
Date: Sun, 21 Jul 2019 08:47:53 +0300
Subject: [PATCH] remove relation to mapdrawing, add relation to history, add
 data column

---
 src/game/game.entity.ts | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/game/game.entity.ts b/src/game/game.entity.ts
index 22e171b..cdea357 100644
--- a/src/game/game.entity.ts
+++ b/src/game/game.entity.ts
@@ -83,16 +83,21 @@ export class ObjectivePointEntity {
   @PrimaryGeneratedColumn('uuid') objectivePointId: string;
   @Column({ type: 'text' }) objectivePointDescription: string;
   @Column({ type: 'float' }) objectivePointMultiplier: number;
+  @Column({ type: 'json' }) data: JSON;
 
-  // If the MapDrawing or Game where the ObjectivePoint was in is deleted, the ObjectivePoint is also deleted
-  @ManyToOne(type => MapDrawingEntity, coordinate => coordinate.data, {
-    onDelete: 'CASCADE',
-  })
-  coordinate: MapDrawingEntity;
+  // If the Game where the ObjectivePoint was in is deleted, the ObjectivePoint is also deleted
   @ManyToOne(type => GameEntity, game => game.objective_points, {
     onDelete: 'CASCADE',
   })
   game: GameEntity;
+  @OneToMany(
+    () => ObjectivePoint_HistoryEntity,
+    history => history.objective_point,
+    {
+      onDelete: 'NO ACTION',
+    },
+  )
+  history: ObjectivePoint_HistoryEntity[];
 }
 
 @Entity('ObjectivePoint_History')
@@ -101,7 +106,7 @@ export class ObjectivePoint_HistoryEntity {
   @Column({ type: 'timestamp' }) oP_HistoryTimestamp: Timestamp;
   @Column('float') action: number;
 
-  // If the owner Faction, capturer Faction or ObjectivePoint, that has, is trying to have or is the point where 
+  // If the owner Faction, capturer Faction or ObjectivePoint, that has, is trying to have or is the point where
   // ObjectivePointHistory points to is deleted, the ObjectivePointHistory is also deleted
   @ManyToOne(type => FactionEntity, factionEntity => factionEntity.factionId, {
     onDelete: 'CASCADE',
-- 
GitLab