import { Column, Entity, PrimaryColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import {
  encodeBigNumberKey,
  decodeBigNumberKey,
} from '../utils/big-number-key';

@Entity('asset_change_assets', { schema: 'public' })
export class AssetChangeAssetEntity {
  @PrimaryColumn({
    name: 'project_id',
    nullable: false,
    transformer: {
      from: (x) => encodeBigNumberKey(x),
      to: (x) => decodeBigNumberKey(x),
    },
  })
  @ApiProperty({})
  projectId: string;

  @PrimaryColumn('uuid', {
    name: 'change_id',
    nullable: false,
  })
  @ApiProperty({ required: true })
  changeId: string;

  @PrimaryColumn('uuid', {
    name: 'asset_id',
  })
  @ApiProperty({})
  assetId: string;

  @Column('jsonb', {
    name: 'undo_change',
  })
  undoChange: Record<string, any>;

  @Column('jsonb', {
    name: 'redo_change',
  })
  redoChange: Record<string, any>;
}
