import {
  BelongsTo,
  Column,
  DataType,
  ForeignKey,
  Model,
  Table,
} from 'sequelize-typescript';
import {
  ActivationTrigger,
  CutOffStatus,
  SourceFeedName,
} from '../enum/feed.enum';
import { IPriceFeedCutOffHistoryAttr } from '../interfaces/price-feed-cut-off-history-attr.interface';
import SourceFeedModel from './price-source-feed.entity';

@Table({
  tableName: 'price_FeedCutOffHistory',
  timestamps: false,
})
export default class FeedCutOffHistoryModel
  extends Model
  implements IPriceFeedCutOffHistoryAttr
{
  @Column({
    primaryKey: true,
    allowNull: false,
    type: DataType.STRING(30),
  })
  FeedCutOffHistoryId: string;

  @ForeignKey(() => SourceFeedModel)
  @Column({
    allowNull: false,
    type: DataType.STRING(50),
  })
  FeedName: SourceFeedName;

  @Column({
    allowNull: false,
    type: DataType.STRING(20),
  })
  Status: CutOffStatus;

  @Column({
    allowNull: false,
    type: DataType.DATE,
  })
  ActivationDateTime: Date;

  @Column({
    allowNull: false,
    type: DataType.STRING(20),
  })
  ActivationTrigger: ActivationTrigger;

  @Column({
    allowNull: true,
    type: DataType.STRING(30),
  })
  ActivatedById: string;

  @Column({
    allowNull: true,
    type: DataType.DATE,
  })
  DeactivationDateTime: Date;

  @Column({
    allowNull: true,
    type: DataType.STRING(30),
  })
  DeactivatedById: string;

  @BelongsTo(() => SourceFeedModel)
  Feed: SourceFeedModel;
}
