const mongoose = require('mongoose');

const migrationSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
    unique: true,
    index: true
  },
  batch: {
    type: Number,
    required: true,
    default: 1
  },
  ranAt: {
    type: Date,
    default: Date.now
  }
}, {
  timestamps: true
});

// Index để tìm kiếm nhanh
migrationSchema.index({ name: 1 });
migrationSchema.index({ batch: -1 });

module.exports = mongoose.model('Migration', migrationSchema);

