const { INTEGER, STRING, TEXT, TINYINT } = require("sequelize");
const sequelize = require("../config/dbconnection");

const DesignEmailLog = sequelize.define('design_email_logs', {
  id: { 
    type: INTEGER, 
    allowNull: false, 
    primaryKey: true, 
    autoIncrement: true 
  },
  design_order_id: { 
    type: INTEGER, 
    allowNull: false 
  },
  recipient_email: { 
    type: STRING(255), 
    allowNull: false 
  },
  cc_emails: { 
    type: TEXT, 
    allowNull: true, 
    defaultValue: null 
  },
  subject: { 
    type: STRING(500), 
    allowNull: false 
  },
  message: { 
    type: TEXT, 
    allowNull: true, 
    defaultValue: null 
  },
  selected_design_ids: { 
    type: TEXT, 
    allowNull: true, 
    defaultValue: null 
  },
  sent_by: { 
    type: INTEGER, 
    allowNull: false 
  },
  user_type: { 
    type: INTEGER, 
    allowNull: false 
  },
  status: { 
    type: TINYINT, 
    allowNull: false, 
    defaultValue: 1 
  },
  error_message: { 
    type: TEXT, 
    allowNull: true, 
    defaultValue: null 
  },
  timestamp: { 
    type: INTEGER, 
    allowNull: false 
  },
  created_at: { 
    type: INTEGER, 
    allowNull: true, 
    defaultValue: null 
  },
}, { 
  timestamps: false, 
  tableName: 'design_email_logs' 
});

module.exports = DesignEmailLog;

