import { DataTypes } from "sequelize";

export default (sequelize) => {
  const PayscribePerson = sequelize.define("PayscribePerson", {
    id: {
      type: DataTypes.UUID,
      defaultValue: DataTypes.UUIDV4,
      primaryKey: true,
    },
    customerId: {
      type: DataTypes.UUID,
      allowNull: false,
      unique: true,
    },
    payscribePersonId: {
      type: DataTypes.STRING,
      allowNull: false,
    },
  }, {
    tableName: "PayscribePersons",
    timestamps: true,
  });

  PayscribePerson.associate = (models) => {
    PayscribePerson.belongsTo(models.Customer, {
      foreignKey: "customerId",
      as: "customer",
    });
  };

  return PayscribePerson;
};
