diff --git a/src/backend/model/database/sql/enitites/FaceRegionEntry.ts b/src/backend/model/database/sql/enitites/FaceRegionEntry.ts deleted file mode 100644 index b0a08d90..00000000 --- a/src/backend/model/database/sql/enitites/FaceRegionEntry.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { FaceRegionBox } from '../../../../../common/entities/PhotoDTO'; -import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; -import { PersonEntry } from './PersonEntry'; -import { MediaEntity } from './MediaEntity'; - -export class FaceRegionBoxEntry implements FaceRegionBox { - @Column('int') - height: number; - @Column('int') - width: number; - @Column('int') - left: number; - @Column('int') - top: number; -} - -/** - * This is a switching table between media and persons - */ -@Entity() -export class FaceRegionEntry { - @PrimaryGeneratedColumn({ unsigned: true }) - id: number; - - @Column((type) => FaceRegionBoxEntry) - box: FaceRegionBoxEntry; - - @ManyToOne((type) => MediaEntity, (media) => media.metadata.faces, { - onDelete: 'CASCADE', - nullable: false, - }) - media: MediaEntity; - - @ManyToOne((type) => PersonEntry, (person) => person.faces, { - onDelete: 'CASCADE', - nullable: false, - }) - person: PersonEntry; - - name: string; -} diff --git a/src/backend/model/database/sql/enitites/PersonJunctionTable.ts b/src/backend/model/database/sql/enitites/PersonJunctionTable.ts new file mode 100644 index 00000000..b2107ce3 --- /dev/null +++ b/src/backend/model/database/sql/enitites/PersonJunctionTable.ts @@ -0,0 +1,28 @@ +import {Entity, Index, ManyToOne, PrimaryGeneratedColumn} from 'typeorm'; +import {PersonEntry} from './PersonEntry'; +import {MediaEntity} from './MediaEntity'; + + +/** + * This is a junction table between media and persons + */ +@Entity() +export class PersonJunctionTable { + @Index() + @PrimaryGeneratedColumn({unsigned: true}) + id: number; + + @Index() + @ManyToOne((type) => MediaEntity, (media) => media.metadata.faces, { + onDelete: 'CASCADE', + nullable: false, + }) + media: MediaEntity; + + @Index() + @ManyToOne((type) => PersonEntry, (person) => person.faces, { + onDelete: 'CASCADE', + nullable: false, + }) + person: PersonEntry; +}