Skip to content
Snippets Groups Projects
Commit dcc8354b authored by Ronnie Friman's avatar Ronnie Friman
Browse files

added onDelete

parent bd94e151
No related branches found
No related tags found
3 merge requests!59Development to master,!36Development,!33Small fixes
......@@ -21,7 +21,9 @@ export class MapDrawingEntity {
onDelete: 'CASCADE',
})
faction: FactionEntity;
@ManyToOne(type => GameEntity, gameEntity => gameEntity.id)
@ManyToOne(type => GameEntity, gameEntity => gameEntity.id, {
onDelete: 'CASCADE',
})
gameId: GameEntity;
}
......@@ -30,8 +32,20 @@ export class Game_Person_MapDrawingEntity {
@PrimaryGeneratedColumn('uuid') GPmapDrawingId: string;
@Column({ type: 'timestamp' }) GPCTimeStamp: Timestamp;
@ManyToOne(type => Game_PersonEntity, game_person => game_person.gamepersonId)
@ManyToOne(
type => Game_PersonEntity,
game_person => game_person.gamepersonId,
{
onDelete: 'CASCADE',
},
)
game_person: Game_PersonEntity;
@ManyToOne(type => MapDrawingEntity, map_drawing => map_drawing.mapDrawingId)
@ManyToOne(
type => MapDrawingEntity,
map_drawing => map_drawing.mapDrawingId,
{
onDelete: 'CASCADE',
},
)
map_drawing: MapDrawingEntity;
}
......@@ -26,15 +26,13 @@ export class FactionEntity {
@Column({ type: 'text' })
factionPassword: string;
@OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction, {
onDelete: 'SET NULL',
})
@OneToMany(type => Game_PersonEntity, game_persons => game_persons.faction)
game_persons: Game_PersonEntity[];
@ManyToOne(type => GameEntity, game => game.factions)
game: GameEntity;
@OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.faction, {
@ManyToOne(type => GameEntity, game => game.factions, {
onDelete: 'CASCADE',
})
game: GameEntity;
@OneToMany(type => MapDrawingEntity, mapDrawings => mapDrawings.faction)
mapDrawings: MapDrawingEntity[];
factionObject() {
......@@ -47,7 +45,7 @@ export class FactionEntity {
}
}
@Entity('PowerUp')
/* @Entity('PowerUp')
export class PowerUpEntity {
@PrimaryGeneratedColumn('uuid') powerUpId: string;
@Column({ type: 'text' }) powerUpName: string;
......@@ -55,7 +53,9 @@ export class PowerUpEntity {
@Column({ type: 'int' }) amount: number;
@Column({ type: 'time' }) cooldown: string;
@OneToMany(type => FactionEntity, factions => factions.factionId)
@OneToMany(type => FactionEntity, factions => factions.factionId, {
onDelete: 'CASCADE',
})
factions: Faction_PowerUpEntity[];
}
......@@ -81,7 +81,7 @@ export class FP_HistoryEntity {
faction_PowerUp => faction_PowerUp.histories,
)
faction_PowerUp: Faction_PowerUpEntity;
}
} */
@Entity('GameGroup')
export class GameGroupEntity {
......
......@@ -57,19 +57,19 @@ export class Game_PersonEntity {
@PrimaryGeneratedColumn('uuid') gamepersonId: string;
@Column({ type: 'text', nullable: true }) role: string;
@ManyToOne(type => FactionEntity, faction => faction.game_persons, {
onDelete: 'SET NULL',
onDelete: 'CASCADE',
})
faction: FactionEntity;
@ManyToOne(type => GameEntity, game => game.id)
@ManyToOne(type => GameEntity, game => game.id, {
onDelete: 'CASCADE',
})
game: GameEntity;
@ManyToOne(type => PersonEntity, person => person.id)
person: PersonEntity;
@OneToOne(type => GameGroupEntity, group => group.leader, {
onDelete: 'CASCADE',
})
@OneToOne(type => GameGroupEntity, group => group.leader)
leaderGroup: GameGroupEntity;
@ManyToOne(type => GameGroupEntity, group => group.players, {
onDelete: 'CASCADE',
onDelete: 'NO ACTION',
})
@JoinColumn({ name: 'group' })
group: GameGroupEntity;
......@@ -81,9 +81,13 @@ export class ObjectivePointEntity {
@Column({ type: 'text' }) objectivePointDescription: string;
@Column({ type: 'float' }) objectivePointMultiplier: number;
@ManyToOne(type => MapDrawingEntity, coordinate => coordinate.data)
@ManyToOne(type => MapDrawingEntity, coordinate => coordinate.data, {
onDelete: 'CASCADE',
})
coordinate: MapDrawingEntity;
@ManyToOne(type => GameEntity, game => game.objective_points)
@ManyToOne(type => GameEntity, game => game.objective_points, {
onDelete: 'CASCADE',
})
game: GameEntity;
}
......@@ -103,6 +107,9 @@ export class ObjectivePoint_HistoryEntity {
@ManyToOne(
type => ObjectivePointEntity,
objective_point => objective_point.objectivePointId,
{
onDelete: 'CASCADE',
},
)
objective_point: string;
}
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn } from "typeorm";
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
} from 'typeorm';
import { GameEntity } from '../game/game.entity';
// temporary table for warning notifications
@Entity('Notifications')
export class NotificationEntity {
@PrimaryGeneratedColumn('uuid') id: string;
@Column({type: 'text'}) message: string;
@CreateDateColumn() issued: Date;
// TODO:
// when game creation has been implemented, add logic so that the notifications are tied to games
}
\ No newline at end of file
@PrimaryGeneratedColumn('uuid') id: string;
@Column({ type: 'text' }) message: string;
@CreateDateColumn() issued: Date;
@ManyToOne(type => GameEntity, game => game.id, {
onDelete: 'CASCADE',
})
game: GameEntity;
}
......@@ -14,6 +14,8 @@ export class ScoreEntity {
@Column({ type: 'float' }) score: number;
@CreateDateColumn({ type: 'timestamp' }) scoreTimeStamp: Timestamp;
@ManyToOne(type => FactionEntity, factionName => factionName.factionId)
@ManyToOne(type => FactionEntity, factionName => factionName.factionId, {
onDelete: 'CASCADE',
})
faction: string;
}
......@@ -24,7 +24,9 @@ export class TaskEntity {
onDelete: 'CASCADE',
})
taskWinner: FactionEntity;
@ManyToOne(type => GameEntity, game => game.id)
@ManyToOne(type => GameEntity, game => game.id, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'taskGame' })
taskGame: GameEntity;
}
......@@ -5,6 +5,8 @@ import { Game_PersonEntity } from '../game/game.entity';
export class TrackingEntity {
@PrimaryGeneratedColumn('uuid') id: string;
@Column({ type: 'json', nullable: true }) data: JSON;
@ManyToOne(type => Game_PersonEntity, person => person.gamepersonId)
@ManyToOne(type => Game_PersonEntity, person => person.gamepersonId, {
onDelete: 'CASCADE',
})
gamepersonId: Game_PersonEntity;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment