feat: allow multiple works per work character

BREAKING CHANGE: This commit replaces the initial typeorm migration.
This commit is contained in:
Xymorot 2020-08-08 18:59:55 +02:00
parent bbc04d4467
commit 40618ce65c
4 changed files with 461 additions and 784 deletions

View File

@ -1,4 +1,4 @@
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { CharacterTag } from './character-tag';
import { InteractionTag } from './interaction-tag';
import { Work } from './work';
@ -23,14 +23,11 @@ export class WorkCharacter implements IIdentifiableEntity, IMultiNamedEntity {
public names!: Promise<WorkCharacterName[]>;
/**
* the work the character is a part of
* the works the character is a part of
* one work character can be part of multiple works because of series
*/
@ManyToOne(() => Work, (work: Work) => work.workCharacters, {
nullable: false,
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
})
public work!: Promise<Work>;
@ManyToMany(() => Work, (work: Work) => work.workCharacters)
public works!: Promise<Work[]>;
/**
* interaction with other characters as actor

View File

@ -62,7 +62,7 @@ export class Work implements IIdentifiableEntity, IMultiNamedEntity {
/**
* characters in this work
*/
@OneToMany(() => WorkCharacter, (workCharacter: WorkCharacter) => workCharacter.work)
@ManyToMany(() => WorkCharacter, (workCharacter: WorkCharacter) => workCharacter.works)
public workCharacters!: Promise<WorkCharacter[]>;
/**

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<mxfile
modified="2020-04-10T01:22:08.923Z"
modified="2020-08-08T16:51:52.280Z"
host="Electron"
agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/12.9.9 Chrome/80.0.3987.163 Electron/8.2.1 Safari/537.36"
etag="td56KXHfCoersQbMeEo0"
version="12.9.9"
agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/13.5.7 Chrome/83.0.4103.122 Electron/9.1.2 Safari/537.36"
etag="8cyIrKWiNQ4HlMxaFiU2"
version="13.5.7"
type="device"
>
<diagram id="7pO8vZOzMzqqcNqUb2yP" name="Library">
<mxGraphModel
dx="4478"
dy="1748"
dx="4120"
dy="1701"
grid="1"
gridSize="10"
guides="1"
@ -1251,7 +1251,7 @@
<mxCell
id="cxYTDXOgWw0TtGYY2s0I-85"
value=""
style="edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERmany;startArrow=ERone;startFill=0;endFill=0;"
style="edgeStyle=entityRelationEdgeStyle;fontSize=12;html=1;endArrow=ERmany;startArrow=ERoneToMany;startFill=0;endFill=0;"
parent="pIilZBVu6Sjv9dfcfJZ6-1"
source="N6cZQSpIyY3U0Nj-7UmH-37"
target="cxYTDXOgWw0TtGYY2s0I-81"