diff --git a/src/draw/coordinate.entity.ts b/src/draw/coordinate.entity.ts index 9cee16c6a496d5e9c68a33eabf57514e88cdf7c1..8f5c4e1d95cd7bf819818664aa41f662a412b316 100644 --- a/src/draw/coordinate.entity.ts +++ b/src/draw/coordinate.entity.ts @@ -17,7 +17,9 @@ export class MapDrawingEntity { @Column({ type: 'json', nullable: true }) data: JSON; - @ManyToOne(type => FactionEntity, faction => faction.mapDrawings) + @ManyToOne(type => FactionEntity, faction => faction.mapDrawings, { + onDelete: 'CASCADE', + }) faction: FactionEntity; @ManyToOne(type => GameEntity, gameEntity => gameEntity.id) gameId: GameEntity; diff --git a/src/faction/faction.entity.ts b/src/faction/faction.entity.ts index 42f3aca413b36455786494818f2ca06f50f50f2e..8bc7548a4f37bf367a6cb0381bc2a131d8080da4 100644 --- a/src/faction/faction.entity.ts +++ b/src/faction/faction.entity.ts @@ -26,11 +26,15 @@ export class FactionEntity { @Column({ type: 'text' }) factionPassword: string; - @OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction) + @OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction, { + onDelete: 'SET NULL', + }) game_persons: Game_PersonEntity[]; @ManyToOne(type => GameEntity, game => game.factions) game: GameEntity; - @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.faction) + @OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.faction, { + onDelete: 'CASCADE', + }) mapDrawings: MapDrawingEntity[]; factionObject() { @@ -102,6 +106,8 @@ export class GameGroupEntity { onDelete: 'CASCADE', }) players: Game_PersonEntity[]; - @ManyToOne(type => FactionEntity, faction => faction.factionId) + @ManyToOne(type => FactionEntity, faction => faction.factionId, { + onDelete: 'CASCADE', + }) faction: FactionEntity; } diff --git a/src/game/game.entity.ts b/src/game/game.entity.ts index 5ff35d56aaeb198d75fc167f380c224b74693f40..c4f4e555ac2bb2aa45bfc0bf2eeac48349f25d86 100644 --- a/src/game/game.entity.ts +++ b/src/game/game.entity.ts @@ -56,7 +56,9 @@ export class GameEntity { export class Game_PersonEntity { @PrimaryGeneratedColumn('uuid') gamepersonId: string; @Column({ type: 'text', nullable: true }) role: string; - @ManyToOne(type => FactionEntity, faction => faction.game_persons) + @ManyToOne(type => FactionEntity, faction => faction.game_persons, { + onDelete: 'SET NULL', + }) faction: FactionEntity; @ManyToOne(type => GameEntity, game => game.id) game: GameEntity; @@ -90,9 +92,13 @@ export class ObjectivePoint_HistoryEntity { @PrimaryGeneratedColumn('uuid') oP_HistoryId: string; @Column({ type: 'timestamp' }) oP_HistoryTimestamp: Timestamp; @Column('float') action: number; - @ManyToOne(type => FactionEntity, factionEntity => factionEntity.factionId) + @ManyToOne(type => FactionEntity, factionEntity => factionEntity.factionId, { + onDelete: 'CASCADE', + }) capture: FactionEntity; - @ManyToOne(type => FactionEntity, factionentity => factionentity.factionId) + @ManyToOne(type => FactionEntity, factionentity => factionentity.factionId, { + onDelete: 'CASCADE', + }) owner: FactionEntity; @ManyToOne( type => ObjectivePointEntity, diff --git a/src/task/task.entity.ts b/src/task/task.entity.ts index 85ee3c26d3830bdb81ebe89bccac93051e0562c7..c8f7d6218f373d8bd213e49dc7b9d6b2ab8ec68e 100644 --- a/src/task/task.entity.ts +++ b/src/task/task.entity.ts @@ -16,9 +16,13 @@ export class TaskEntity { @Column({ type: 'text' }) taskDescription: string; @Column({ type: 'bool' }) taskIsActive: boolean; - @ManyToOne(type => FactionEntity, faction => faction.factionId) + @ManyToOne(type => FactionEntity, faction => faction.factionId, { + onDelete: 'CASCADE', + }) faction: FactionEntity; - @ManyToOne(type => FactionEntity, faction => faction.factionId) + @ManyToOne(type => FactionEntity, faction => faction.factionId, { + onDelete: 'CASCADE', + }) taskWinner: FactionEntity; @ManyToOne(type => GameEntity, game => game.id) @JoinColumn({ name: 'taskGame' })