<?php

declare(strict_types=1);

use App\Infrastructure\Db\Migrations\BaseMigration;

final class CreateOidcRoleMappings extends BaseMigration
{
    public function change(): void
    {
        $table = $this->table('oidc_role_mappings');
        $table
            ->addColumn('group_id', 'string', ['limit' => 128, 'null' => false])
            ->addColumn('role', 'string', ['limit' => 32, 'null' => false]);

        $this->addTimestampColumn($table, 'created_at');

        $table
            ->addIndex(['group_id'], ['unique' => true, 'name' => 'uniq_oidc_role_mappings_group_id'])
            ->create();
    }
}
