<?php
namespace Core\Database\Operations;

use Core\Database\Schema;
use Core\Database\MigrationOperation;

class DropIndex implements MigrationOperation
{
    protected string $table;
    protected string $indexName;

    public function __construct(string $table, string $indexName)
    {
        $this->table = $table;
        $this->indexName = $indexName;
    }

    public function up()
    {
        Schema::dropIndex($this->table, $this->indexName);
    }

    public function down()
    {
        throw new \Exception("Cannot rollback DropIndex: no column info for index '{$this->indexName}'.");
    }
}
