const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const ProductVariant = sequelize.define('ProductVariant', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  productId: { type: DataTypes.INTEGER, allowNull: false, field: 'product_id' },
  type: { type: DataTypes.STRING(50), allowNull: false },
  value: { type: DataTypes.STRING(100), allowNull: false },
  priceModifier: { type: DataTypes.DECIMAL(10, 2), defaultValue: 0, field: 'price_modifier' },
  stock: { type: DataTypes.INTEGER, defaultValue: 0 },
  sku: { type: DataTypes.STRING(50) },
  isActive: { type: DataTypes.BOOLEAN, defaultValue: true, field: 'is_active' },
}, {
  tableName: 'product_variants',
  timestamps: true,
  underscored: true,
});

module.exports = ProductVariant;
