import { DataTypes } from "sequelize";

export default (sequelize) => {
  const WebhookLog = sequelize.define("WebhookLog", {
    id: {
      type: DataTypes.UUID,
      defaultValue: DataTypes.UUIDV4,
      primaryKey: true,
    },
    payload: {
      type: DataTypes.JSON,
      allowNull: false,
    },
    status: {
      type: DataTypes.ENUM("received", "processed", "failed"),
      defaultValue: "received",
    },
    message: {
      type: DataTypes.TEXT,
      allowNull: true,
    },
  }, {
    timestamps: true,
  });

  return WebhookLog;
};
