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

@Entity('state')
export class State {
  @PrimaryGeneratedColumn({ name: 'state_id' })
  state_id: number;

  @Column({ type: 'int', default: 1 })
  country_id: number;

  @Column({ type: 'varchar', length: 80 })
  state_name: string;

  @Column({ type: 'int', default: 1 })
  status: number;

  @Column({
    type: 'varchar',
    length: 2,
    nullable: true,
    comment: 'GST state code as per GST Act',
  })
  gst_code: string;

  @CreateDateColumn({
    name: 'created_at',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createdAt: Date;

  @UpdateDateColumn({
    name: 'updated_at',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
  })
  updatedAt: Date;
}
