added subspace and space product allocation entity

This commit is contained in:
hannathkadher
2025-02-10 12:58:49 +04:00
parent 8d4e10ff1c
commit 4c7208cd5f
5 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import { Entity, Column, ManyToOne, ManyToMany, JoinTable } from 'typeorm';
import { SpaceEntity } from './space.entity';
import { SpaceModelProductAllocationEntity } from '../../space-model';
import { ProductEntity } from '../../product/entities';
import { NewTagEntity } from '../../tag';
@Entity({ name: 'space_product_allocation' })
export class SpaceProductAllocationEntity {
@Column({
type: 'uuid',
default: () => 'gen_random_uuid()',
nullable: false,
})
public uuid: string;
@ManyToOne(() => SpaceEntity, (space) => space.productAllocations, {
nullable: false,
onDelete: 'CASCADE',
})
public space: SpaceEntity;
@ManyToOne(() => SpaceModelProductAllocationEntity, {
nullable: true,
onDelete: 'SET NULL',
})
public inheritedFromModel?: SpaceModelProductAllocationEntity;
@ManyToOne(() => ProductEntity, { nullable: false, onDelete: 'CASCADE' })
public product: ProductEntity;
@Column({ type: 'int', default: 1 })
public allowedQuantity: number;
@ManyToMany(() => NewTagEntity)
@JoinTable({ name: 'space_product_tags' })
public allowedTags: NewTagEntity[];
}