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

const Customer = sequelize.define('customers', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  email: { type: DataTypes.STRING(100), unique: true, allowNull: false },
  full_name: { type: DataTypes.STRING(100), allowNull: false },
  phone: { type: DataTypes.STRING(20), allowNull: false },
  address: { type: DataTypes.TEXT },
  passport_number: { type: DataTypes.STRING(20) },
  nationality: { type: DataTypes.STRING(50) },
  date_of_birth: { type: DataTypes.DATEONLY },
  preferred_language: { type: DataTypes.STRING(20), defaultValue: 'English' },
  newsletter_subscribed: { type: DataTypes.BOOLEAN, defaultValue: false },
  total_bookings: { type: DataTypes.INTEGER, defaultValue: 0 },
  total_spent: { type: DataTypes.DECIMAL(10, 2), defaultValue: 0.0 },
}, {
  timestamps: true,
  createdAt: 'created_at',
  updatedAt: 'updated_at',
});

module.exports = Customer;
