import { User } from '../../../repositories/users/entity/user.entity';
import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  OneToMany,
} from 'typeorm';

@Entity({ name: 'accounts' })
export class Account {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ nullable: true })
  parent_account_id?: number;

  @Column()
  tier: number;

  @Column()
  country: string;

  @Column({ default: false })
  delegation_permission: boolean;

  @Column({ default: false })
  locked: boolean;

  @Column()
  company_name: string;

  @Column({ default: false })
  verified: boolean;

  @Column({ nullable: true })
  primary_admin_user_id?: number;

  @Column({ nullable: true })
  secondary_admin_user_id?: number;

  @Column({ nullable: true })
  deleted_at?: Date;

  @Column({ nullable: true })
  created_by?: string;

  @CreateDateColumn({ default: () => "datetime('now', 'localtime')" }) // defaultはSQLite用設定値.本番用は別途migrationで設定
  created_at: Date;

  @Column({ nullable: true })
  updated_by?: string;

  @UpdateDateColumn({ default: () => "datetime('now', 'localtime')" }) // defaultはSQLite用設定値.本番用は別途migrationで設定
  updated_at: Date;

  @OneToMany(() => User, (user) => user.id)
  user?: User[];
}
