'use strict';

module.exports = (sequelize, DataTypes) => {
    const Goods = sequelize.define('Goods', {
        id: {
            allowNull: false,
            autoIncrement: true,
            primaryKey: true,
            type: DataTypes.INTEGER
        },
        goodsName: {
            allowNull: false,
            type: DataTypes.STRING
        },
        goodsDescription: {
          allowNull: false,
          type: DataTypes.STRING
        },
        isSale: {
          allowNull: false,
          type: DataTypes.BOOLEAN,
          defaultValue: false
        },
        goodsFullDescription: {
          allowNull: false,
          type: DataTypes.TEXT("long")
        },
        goodsBrandId: {
            allowNull: false,
            type: DataTypes.INTEGER
        },
        goodsGroupId: {
            allowNull: false,
            type: DataTypes.INTEGER
        },
        goodsGender: {
            allowNull: false,
            type: DataTypes.STRING
        },
        goodsMadeIn: {
            allowNull: false,
            type: DataTypes.STRING
        },
        volumesArray: {
            allowNull: false,
            type: DataTypes.ARRAY(DataTypes.TEXT),
            defaultValue: []
        },
    });

    Goods.associate = function (models) {
        Goods.hasMany(models.GoodsAttributes, {foreignKey: 'goodsId', targetKey: "id"})
    };

    return Goods;
};
