import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { CharacterEntity } from './character.entity';
import { PropertyEntity } from './property.entity';

@Entity('property_keys')
export class PropertyKeyEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column() property_id: number;
    @Column() character_id: number;
    @Column() issued_by_character_id: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) issued: Date;
    @Column({ type: 'tinyint', width: 1 }) furniture: boolean;
    @Column({ type: 'tinyint', width: 1 }) furniture_adjust: boolean;
    @Column({ type: 'tinyint', width: 1 }) spawn: boolean;

    @ManyToOne(() => CharacterEntity, (character) => character.propertyKeys)
    @JoinColumn({ name: 'character_id' })
    character: CharacterEntity;

    @ManyToOne(() => PropertyEntity, (property) => property.propertyKeys)
    @JoinColumn({ name: 'property_id' })
    property: PropertyEntity;
}
