From c193a63785fa32b335880e6378d36e9760ffef00 Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Mon, 23 Nov 2020 13:37:26 +0100 Subject: [PATCH] src/model*: unique fields added unique contraines to some fields. For Example, name of CargoBike, workshopType and the combination of name and firstName of Person. --- src/model/CargoBike.ts | 4 +++- src/model/EngagementType.ts | 4 +++- src/model/EquipmentType.ts | 4 +++- src/model/Organisation.ts | 4 +++- src/model/Person.ts | 3 ++- src/model/WorkshopType.ts | 4 +++- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/model/CargoBike.ts b/src/model/CargoBike.ts index 2ea30b0..81fb218 100644 --- a/src/model/CargoBike.ts +++ b/src/model/CargoBike.ts @@ -183,7 +183,9 @@ export class CargoBike implements Lockable { }) group: Group; - @Column() + @Column({ + unique: true + }) name: string; @OneToMany(type => Equipment, equipment => equipment.cargoBikeId, { diff --git a/src/model/EngagementType.ts b/src/model/EngagementType.ts index 01469f2..cdd816e 100644 --- a/src/model/EngagementType.ts +++ b/src/model/EngagementType.ts @@ -26,7 +26,9 @@ export class EngagementType implements Lockable { @PrimaryGeneratedColumn() id: number; - @Column() + @Column({ + unique: true + }) name: string; @Column({ diff --git a/src/model/EquipmentType.ts b/src/model/EquipmentType.ts index 38647f6..f8fd0b7 100644 --- a/src/model/EquipmentType.ts +++ b/src/model/EquipmentType.ts @@ -25,7 +25,9 @@ export class EquipmentType implements Lockable { @PrimaryGeneratedColumn() id: number; - @Column() + @Column({ + unique: true + }) name: string; @Column({ diff --git a/src/model/Organisation.ts b/src/model/Organisation.ts index 279d47c..80857d5 100644 --- a/src/model/Organisation.ts +++ b/src/model/Organisation.ts @@ -28,7 +28,9 @@ export class Organisation implements Lockable { @PrimaryGeneratedColumn() id: number; - @Column() + @Column({ + unique: true + }) name: string; @OneToMany(type => LendingStation, lendingStation => lendingStation.organisationId) diff --git a/src/model/Person.ts b/src/model/Person.ts index 9d1fafa..e383969 100644 --- a/src/model/Person.ts +++ b/src/model/Person.ts @@ -18,10 +18,11 @@ This file is part of fLotte-API-Server. */ import { Lockable } from './CargoBike'; -import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; +import { Column, Entity, OneToMany, PrimaryGeneratedColumn, Unique } from 'typeorm'; import { ContactInformation } from './ContactInformation'; @Entity() +@Unique(['firstName', 'name']) export class Person implements Lockable { @PrimaryGeneratedColumn() id: number; diff --git a/src/model/WorkshopType.ts b/src/model/WorkshopType.ts index 3322da2..40d922e 100644 --- a/src/model/WorkshopType.ts +++ b/src/model/WorkshopType.ts @@ -26,7 +26,9 @@ export class WorkshopType implements Lockable { @PrimaryGeneratedColumn() id: number; - @Column() + @Column({ + unique: true + }) name: string; @OneToMany(type => Workshop, workshop => workshop.workshopTypeId)