<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20260218135819 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Add image rights columns to users table';
    }

    public function up(Schema $schema): void
    {
        $this->addSql(<<<'SQL'
            ALTER TABLE users
                ADD COLUMN image_rights_status VARCHAR(20) NOT NULL DEFAULT 'not_specified',
                ADD COLUMN image_rights_updated_at TIMESTAMPTZ,
                ADD COLUMN image_rights_updated_by UUID REFERENCES users(id)
        SQL);

        $this->addSql(<<<'SQL'
            CREATE INDEX idx_users_image_rights ON users(image_rights_status)
        SQL);
    }

    public function down(Schema $schema): void
    {
        $this->addSql('DROP INDEX IF EXISTS idx_users_image_rights');
        $this->addSql(<<<'SQL'
            ALTER TABLE users
                DROP COLUMN IF EXISTS image_rights_status,
                DROP COLUMN IF EXISTS image_rights_updated_at,
                DROP COLUMN IF EXISTS image_rights_updated_by
        SQL);
    }
}
