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

@Entity('ajails')
export class AdminJailEntity {
    @PrimaryGeneratedColumn() id: number;
    @Index()
    @Column()
    account_id: number;
    @Column({ type: 'varchar', length: 64 }) account_name: string;
    @Index()
    @Column()
    character_id: number;
    @Column({ type: 'varchar', length: 64 }) character_name: string;
    @Column({ type: 'varchar', length: 16 }) player_ip: string;
    @Column({ type: 'int', nullable: true }) ajailer_account_id: number | null;
    @Column({ type: 'varchar', length: 64 }) ajailer_name: string;
    @Column({ type: 'varchar', length: 256 }) reason: string;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) date: string;
    @Column() length: number;
    @Column() remaining_length: number;
    @Column({ type: 'datetime', default: null }) served: string | null;
    @Column({ type: 'datetime', default: null }) voided: string | null;

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