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

const Client = sequelize.define('Client', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  client_name: {
    type: DataTypes.STRING(100),
    allowNull: false,
  },
  mobile: {
    type: DataTypes.STRING(15),
    allowNull: false,
  },
  landline: {
    type: DataTypes.STRING(15),
    allowNull: false,
  },
  email: {
    type: DataTypes.STRING(100),
    allowNull: false,
    defaultValue: '',
  },
  address: {
    type: DataTypes.STRING(250),
    allowNull: false,
  },
  details: {
    type: DataTypes.STRING(500),
    allowNull: false,
  },
  created_at: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW
  },
  status: {
    type: DataTypes.SMALLINT,
    allowNull: false,
    defaultValue: 1,
  },
}, {
  tableName: 'client',        // Use existing table name
  schema: 'public',           // Specify schema
  timestamps: false,          // Disable automatic timestamps since we have created_at only
  createdAt: false,          // No automatic createdAt
  updatedAt: false           // No automatic updatedAt
});

export default Client;