import {
  Entity, Column, PrimaryGeneratedColumn, CreateDateColumn,
  UpdateDateColumn, VersionColumn, Index,
} from 'typeorm';

@Entity('wallets')
@Index('idx_wallets_user', ['userId'])
export class Wallet {
  @PrimaryGeneratedColumn('uuid') id: string;
  @Column({ name: 'user_id', type: 'uuid', unique: true }) userId: string;
  @Column({ type: 'numeric', precision: 20, scale: 8, default: '0' }) balance: string;
  @Column({ name: 'frozen_balance', type: 'numeric', precision: 20, scale: 8, default: '0' }) frozenBalance: string;
  @Column({ type: 'varchar', length: 10, default: 'USD' }) currency: string;
  @Column({ type: 'varchar', length: 20, default: 'active' }) status: string;
  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date;
  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' }) updatedAt: Date;
  @VersionColumn({ default: 1 }) version: number;
}
