/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/application-client.aurora.yaml
 */
import { OAuthApplicationModel } from '@app/o-auth/application';
import { OAuthClientModel } from '@app/o-auth/client';
import { Auditable } from '@aurorajs.dev/core-back';
import { DataTypes } from 'sequelize';
import { BelongsTo, Column, ForeignKey, Model, Table } from 'sequelize-typescript';

@Auditable()
@Table({
  modelName: 'OAuthApplicationClient',
  tableName: 'o_auth_application_client',
  freezeTableName: true,
  timestamps: false,
})
export class OAuthApplicationClientModel extends Model<OAuthApplicationClientModel> {
  @ForeignKey(() => OAuthApplicationModel)
  @Column({
    field: 'application_id',
    primaryKey: true,
    allowNull: false,
    type: DataTypes.UUID,
  })
  applicationId: string;

  @BelongsTo(() => OAuthApplicationModel, {
    constraints: false,
    foreignKey: 'application_id',
  })
  application: OAuthApplicationModel;

  @ForeignKey(() => OAuthClientModel)
  @Column({
    field: 'client_id',
    primaryKey: true,
    allowNull: false,
    type: DataTypes.UUID,
  })
  clientId: string;

  @BelongsTo(() => OAuthClientModel, {
    constraints: false,
    foreignKey: 'client_id',
  })
  client: OAuthClientModel;
}
