'use strict'
const { Model, DataTypes } = require('sequelize')

module.exports = (sequelize) => {
  class BugReporting extends Model {
    static associate(models) {
      // Define associations, if any
    }
  }

  BugReporting.init(
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
        allowNull: false,
      },
      class: {
        type: DataTypes.STRING(191),
        allowNull: true,
      },
      file: {
        type: DataTypes.STRING(191),
        allowNull: true,
      },
      code: {
        type: DataTypes.INTEGER,
        allowNull: true,
      },
      status_code: {
        type: DataTypes.INTEGER,
        allowNull: true,
        defaultValue: 0,
      },
      line: {
        type: DataTypes.INTEGER,
        allowNull: true,
      },
      message: {
        type: DataTypes.TEXT,
        allowNull: true,
      },
      trace: {
        type: DataTypes.TEXT,
        allowNull: true,
      },
      user_id: {
        type: DataTypes.UUID,
        defaultValue: null,
        allowNull: true,
      },
      data: {
        type: DataTypes.TEXT,
        defaultValue: null,
        allowNull: true,
      },
      url: {
        type: DataTypes.TEXT,
        defaultValue: null,
        allowNull: true,
      },
      method: {
        type: DataTypes.STRING(191),
        defaultValue: null,
        allowNull: true,
      },
      ip: {
        type: DataTypes.STRING(191),
        defaultValue: null,
        allowNull: true,
      },
      updated_at: {
        type: DataTypes.DATE,
        allowNull: true,
      },
      deleted_at: {
        type: DataTypes.DATE,
        allowNull: true,
      },
      created_by: {
        type: DataTypes.UUID,
        allowNull: true,
      },
      updated_by: {
        type: DataTypes.UUID,
        allowNull: true,
      }
    },
    {
      sequelize,
      modelName: 'BugReporting',
      tableName: 'core_bug_reportings',
      timestamps: true,
      createdAt: 'created_at',
      updatedAt: 'updated_at',
      deletedAt: 'deleted_at',
    }
  )

  return BugReporting
}
