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

@Entity('money_logs')
export class MoneyLogEntity {
    @PrimaryGeneratedColumn() id: number;
    @Index()
    @Column()
    character_id: number;
    @Column() account_id: number;
    @Column() amount: number;
    @Column() before: number;
    @Column() after: number;
    @Column({ type: 'varchar', length: 64 }) method: string;
    @Column({ type: 'varchar', length: 200, default: null, nullable: true }) reason: string;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) date: string;

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