Emergency fix: Switched to table inheritances

ref #11 #13
This commit is contained in:
Nicolai Ort 2020-12-03 20:28:07 +01:00
parent e3133e0d5e
commit a8956223c2
8 changed files with 30 additions and 27 deletions

View File

@ -1,4 +1,4 @@
import { Entity, Column, ManyToOne } from "typeorm";
import { Entity, Column, ManyToOne, ChildEntity } from "typeorm";
import { IsInt, IsNotEmpty, IsPositive, } from "class-validator";
import { Donation } from "./Donation";
import { Runner } from "./Runner";
@ -7,7 +7,7 @@ import { Runner } from "./Runner";
* Defines a distance based donation.
* Here people donate a certain amout per kilometer
*/
@Entity()
@ChildEntity()
export class DistanceDonation extends Donation {
/**
* The runner associated.

View File

@ -1,4 +1,4 @@
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from "typeorm";
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, TableInheritance } from "typeorm";
import {
IsInt,
IsNotEmpty,
@ -11,6 +11,7 @@ import { Participant } from "./Participant";
* Defines the donation interface.
*/
@Entity()
@TableInheritance({ column: { name: "type", type: "varchar" } })
export abstract class Donation {
/**
* Autogenerated unique id (primary key).

View File

@ -1,11 +1,11 @@
import { Entity, Column } from "typeorm";
import { Entity, Column, ChildEntity } from "typeorm";
import { IsBoolean } from "class-validator";
import { Participant } from "./Participant";
/**
* Defines a donor.
*/
@Entity()
@ChildEntity()
export class Donor extends Participant {
/**
* Does this donor need a receipt?.

View File

@ -1,11 +1,11 @@
import { Entity, Column } from "typeorm";
import { Entity, Column, ChildEntity } from "typeorm";
import { IsInt, IsPositive, } from "class-validator";
import { Donation } from "./Donation";
/**
* Defines a fixed donation.
*/
@Entity()
@ChildEntity()
export class FixedDonation extends Donation {
/**

View File

@ -1,4 +1,4 @@
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne, Entity } from "typeorm";
import { PrimaryGeneratedColumn, Column, OneToMany, ManyToOne, Entity, TableInheritance } from "typeorm";
import {
IsEmail,
IsInt,
@ -15,6 +15,7 @@ import { Donation } from "./Donation";
* Defines the participant interface.
*/
@Entity()
@TableInheritance({ column: { name: "type", type: "varchar" } })
export abstract class Participant {
/**
* Autogenerated unique id (primary key).

View File

@ -1,4 +1,4 @@
import { Entity, Column, OneToMany, ManyToOne } from "typeorm";
import { Entity, Column, OneToMany, ManyToOne, ChildEntity } from "typeorm";
import { IsInt, IsNotEmpty, } from "class-validator";
import { Participant } from "./Participant";
import { RunnerGroup } from "./RunnerGroup";
@ -9,7 +9,7 @@ import { Scan } from "./Scan";
/**
* Defines a runner.
*/
@Entity()
@ChildEntity()
export class Runner extends Participant {
/**
* The runner's associated group.

View File

@ -1,4 +1,4 @@
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from "typeorm";
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, TableInheritance } from "typeorm";
import {
IsBoolean,
IsInt,
@ -12,6 +12,7 @@ import { Runner } from "./Runner";
* Defines the scan interface.
*/
@Entity()
@TableInheritance({ column: { name: "type", type: "varchar" } })
export abstract class Scan {
/**
* Autogenerated unique id (primary key).

View File

@ -1,4 +1,4 @@
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity } from "typeorm";
import { PrimaryGeneratedColumn, Column, ManyToOne, Entity, ChildEntity } from "typeorm";
import {
IsBoolean,
IsDateString,
@ -16,7 +16,7 @@ import { ScanStation } from "./ScanStation";
/**
* Defines the scan interface.
*/
@Entity()
@ChildEntity()
export class TrackScan extends Scan {
/**
* The associated track.