class CreateDataImports < ActiveRecord::Migration[8.1]
  def change
    create_table :data_imports do |t|
      t.string :import_type, null: false, comment: "ASN or Country import"
      t.string :status, null: false, default: "pending", comment: "pending, processing, completed, failed"
      t.string :filename, null: false
      t.integer :total_records, default: 0
      t.integer :processed_records, default: 0
      t.integer :failed_records, default: 0
      t.text :error_message
      t.json :import_stats, default: {}, comment: "Detailed import statistics"
      t.datetime :started_at
      t.datetime :completed_at
      t.timestamps
    end

    add_index :data_imports, :status
    add_index :data_imports, :import_type
    add_index :data_imports, :created_at
  end
end
