<?php

declare(strict_types=1);

use App\Infrastructure\Db\Migrations\BaseMigration;

final class CreateCategories extends BaseMigration
{
    public function change(): void
    {
        $table = $this->table('categories');
        $table
            ->addColumn('slug', 'string', ['limit' => 64, 'null' => false])
            ->addColumn('name', 'string', ['limit' => 128, 'null' => false])
            ->addColumn('description', 'text', ['null' => true])
            ->addColumn('decay_function', 'string', ['limit' => 32, 'null' => false])
            ->addColumn('decay_param', 'decimal', ['precision' => 10, 'scale' => 4, 'null' => false])
            ->addColumn('is_active', 'boolean', ['null' => false, 'default' => true])
            ->addIndex(['slug'], ['unique' => true, 'name' => 'uniq_categories_slug'])
            ->create();
    }
}
