import { DB_SCHEMA } from 'src/utils';
import { IColumnConfig } from 'src/utils/interfaces/config';
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('lms_table_settings', { schema: DB_SCHEMA })
export class LmsTableSettingsEntity {
  @PrimaryGeneratedColumn({ type: 'mediumint', name: 'id' })
  id: number;

  @Column('smallint', { name: 'user_id' })
  user_id: number;

  @Column('smallint', { name: 'affiliate_user_id', nullable: true })
  affiliate_user_id: number | null;

  @Column('text', { name: 'settings' })
  settings: string;

  @Column('json', { name: 'setting_pack', nullable: true })
  setting_pack: IColumnConfig[] | null;

  @Column('varchar', { name: 'setting_type', length: 200 })
  setting_type: string;

  @Column('smallint', { name: 'record_per_page', default: () => "'50'" })
  record_per_page: number;

  @Column('timestamp', {
    name: 'created_on',
    default: () => 'CURRENT_TIMESTAMP',
  })
  created_on: Date;

  @Column('timestamp', {
    name: 'updated_on',
    default: () => 'CURRENT_TIMESTAMP',
  })
  updated_on: Date;
}
