/**
 * @aurora-catalyst-generated
 * @source cliter/iam/tenant-account.aurora.yaml
 */
import { IamAccountModel } from '@app/iam/account';
import { IamTenantModel } from '@app/iam/tenant';
import { Auditable } from '@aurorajs.dev/core-back';
import { DataTypes } from 'sequelize';
import { BelongsTo, Column, ForeignKey, Model, Table } from 'sequelize-typescript';

@Auditable()
@Table({
  modelName: 'IamTenantAccount',
  tableName: 'iam_tenant_account',
  freezeTableName: true,
  timestamps: false,
})
export class IamTenantAccountModel extends Model<IamTenantAccountModel> {
  @ForeignKey(() => IamTenantModel)
  @Column({
    field: 'tenant_id',
    primaryKey: true,
    allowNull: false,
    type: DataTypes.UUID,
  })
  tenantId: string;

  @BelongsTo(() => IamTenantModel, {
    constraints: false,
    foreignKey: 'tenant_id',
  })
  tenant: IamTenantModel;

  @ForeignKey(() => IamAccountModel)
  @Column({
    field: 'account_id',
    primaryKey: true,
    allowNull: false,
    type: DataTypes.UUID,
  })
  accountId: string;

  @BelongsTo(() => IamAccountModel, {
    constraints: false,
    foreignKey: 'account_id',
  })
  account: IamAccountModel;
}
