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

const Mapping = sequelize.define('Mapping', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  login_id: { type: DataTypes.INTEGER, allowNull: false },
  treelogy_id: { type: DataTypes.INTEGER, allowNull: false },         // added
  description: { type: DataTypes.STRING(50), allowNull: false },
  code: { type: DataTypes.STRING(50), allowNull: false },
  role: { type: DataTypes.STRING(50), allowNull: false },
  view_permission: { type: DataTypes.STRING(50), allowNull: false },
  profile: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 },
  status: { type: DataTypes.SMALLINT, allowNull: false, defaultValue: 1 },
  created_by: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 },
  created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, // map the column
  sort_order: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 },          // added
  current_map_year: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 },
}, {
  tableName: 'mapping',
  schema: 'public',
  timestamps: false // use created_at column explicitly
});

export default Mapping;
