<?php
namespace Core\Database\Operations;

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

class AddIndex implements MigrationOperation
{
    protected string $table;
    protected string $indexName;
    protected array $columns;

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

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

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