<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

final class Version20260506200000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Rename rotation_interval_hours to rotation_interval_minutes (1 hour = 60 minutes)';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE device RENAME COLUMN rotation_interval_hours TO rotation_interval_minutes');
        $this->addSql('ALTER TABLE device ALTER COLUMN rotation_interval_minutes SET DEFAULT 1440');
        $this->addSql('UPDATE device SET rotation_interval_minutes = rotation_interval_minutes * 60');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('UPDATE device SET rotation_interval_minutes = rotation_interval_minutes / 60');
        $this->addSql('ALTER TABLE device ALTER COLUMN rotation_interval_minutes SET DEFAULT 24');
        $this->addSql('ALTER TABLE device RENAME COLUMN rotation_interval_minutes TO rotation_interval_hours');
    }
}
