const {DataTypes} = require("sequelize")

module.exports = (sequelize) => {
  const Watchlist = sequelize.define(
    "Watchlist",
    {
      id: {
        type: DataTypes.BIGINT.UNSIGNED,
        primaryKey: true,
        autoIncrement: true,
      },

      userId: {
        type: DataTypes.BIGINT.UNSIGNED,
        allowNull: false,
        field: "user_id",
      },

      assetId: {
        type: DataTypes.BIGINT.UNSIGNED,
        allowNull: false,
        field: "asset_id",
      },
    },
    {
      tableName: "watchlists",
      underscored: true,
      indexes: [
        {
          unique: true,
          fields: ["user_id", "asset_id"],
        },
      ],
    }
  );

  return Watchlist;
};