import { DataTypes } from 'sequelize';
import sequelize from '../config/database.js';

const Icon = sequelize.define('Icon', {
  id: {
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV4,
    primaryKey: true
  },
  projectId: {
    type: DataTypes.UUID,
    allowNull: false,
    references: {
      model: 'Projects',
      key: 'id'
    }
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false
  },
  category: {
    type: DataTypes.STRING,
    allowNull: true
  },
  svgData: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  sizes: {
    type: DataTypes.JSON,
    defaultValue: ['16', '24', '32', '48']
  },
  figmaId: {
    type: DataTypes.STRING,
    allowNull: true
  },
  usageCount: {
    type: DataTypes.INTEGER,
    defaultValue: 0
  },
  tags: {
    type: DataTypes.JSON,
    defaultValue: []
  },
  createdAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW
  },
  updatedAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW
  }
}, {
  timestamps: true,
  indexes: [
    { fields: ['projectId'] },
    { fields: ['category'] }
  ]
});

export default Icon;
