module.exports = function(sequelize, DataTypes) {
  const funding_opportunities = sequelize.define(
    'funding_opportunities',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },
      name: {
        type: DataTypes.TEXT,
      },
      focus: {
        type: DataTypes.TEXT,
      },
      stage: {
        type: DataTypes.TEXT,
      },
      contact_type: {
        type: DataTypes.TEXT,
      },
      description: {
        type: DataTypes.TEXT,
      },
      website: {
        type: DataTypes.TEXT,
      },
      amount_min: {
        type: DataTypes.DECIMAL,
      },
      amount_max: {
        type: DataTypes.DECIMAL,
      },
      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  funding_opportunities.associate = (db) => {
    db.funding_opportunities.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.funding_opportunities.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };

  return funding_opportunities;
};
