import { DataTypes } from 'sequelize';

export default function defineUser(sequelize) {
  return sequelize.define(
    'User',
    {
      id: { type: DataTypes.BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true },
      name: { type: DataTypes.STRING(120), allowNull: false, defaultValue: '' },
      phone: { type: DataTypes.STRING(20), allowNull: false, unique: true },
      role: {
        type: DataTypes.ENUM('customer', 'employee', 'admin', 'super_admin'),
        allowNull: false,
        defaultValue: 'customer',
      },
      created_at: {
        type: DataTypes.DATE(3),
        allowNull: false,
        defaultValue: DataTypes.NOW,
      },
    },
    { tableName: 'users' }
  );
}
