const { Sequelize, DataTypes } = require('sequelize');

const { DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD } = process.env;

const sequelize = new Sequelize(DB_NAME, DB_USER, DB_PASSWORD, {
  host: DB_HOST,
  port: DB_PORT,
  dialect: 'mysql',
});

const Item = sequelize.define(
  'Items',
  {
    item_id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true, unique: true },
    pid: { type: DataTypes.INTEGER },
    description: { type: DataTypes.STRING, allowNull: false },
    sold: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false },
  },
  { timestamps: false },
);

export { Item, sequelize };
