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

const TaxiMapTile = sequelize.define('TaxiMapTile', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
  },
  mapId: {
    type: DataTypes.INTEGER,
    allowNull: false,
  },
  x: {
    type: DataTypes.INTEGER,
    allowNull: false,
  },
  y: {
    type: DataTypes.INTEGER,
    allowNull: false,
  },
  tileType: {
    type: DataTypes.STRING(50),
    allowNull: false,
  },
  trafficLight: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: false,
    comment: 'Whether this tile has a traffic light'
  },
  meta: {
    type: DataTypes.JSON,
    allowNull: true,
  }
}, {
  tableName: 'taxi_map_tile',
  schema: 'taxi',
  timestamps: true,
  underscored: true,
  indexes: [
    { unique: true, fields: ['map_id','x','y'] },
    { fields: ['map_id'] },
    { fields: ['tile_type'] },
    { fields: ['traffic_light'] },
  ]
});

export default TaxiMapTile;


