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

const ProductImage = sequelize.define('ProductImage', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  productId: { type: DataTypes.INTEGER, allowNull: false, field: 'product_id' },
  imagePath: { type: DataTypes.STRING, allowNull: false, field: 'image_path' },
  isPrimary: { type: DataTypes.BOOLEAN, defaultValue: false, field: 'is_primary' },
  sortOrder: { type: DataTypes.INTEGER, defaultValue: 0, field: 'sort_order' },
  altText: { type: DataTypes.STRING(200), field: 'alt_text' },
}, {
  tableName: 'product_images',
  timestamps: true,
  underscored: true,
});

module.exports = ProductImage;
