<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20240929171054 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE users ADD first_name VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE users ADD last_name VARCHAR(255) DEFAULT NULL');
        $this->addSql('CREATE TABLE reset_password_request (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, selector VARCHAR(20) NOT NULL, hashed_token VARCHAR(100) NOT NULL, requested_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, expires_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, user_id INT NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_7CE748AA76ED395 ON reset_password_request (user_id)');
        $this->addSql('ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('TRUNCATE logs');
        $this->addSql('ALTER TABLE logs ADD state INT NOT NULL');
        $this->addSql('ALTER TABLE logs ADD mailcount INT NOT NULL');
        $this->addSql('ALTER TABLE logs DROP success');
        $this->addSql('ALTER TABLE logs ALTER message SET NOT NULL');
        $this->addSql('ALTER TABLE logs ALTER details SET NOT NULL');
        $this->addSql('TRUNCATE config');
        $this->addSql('ALTER TABLE config DROP CONSTRAINT config_pkey');
        $this->addSql('ALTER TABLE config ADD type VARCHAR(16) NOT NULL');
        $this->addSql('ALTER TABLE config RENAME COLUMN name TO key');
        $this->addSql('ALTER TABLE config ADD PRIMARY KEY (key)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE users DROP first_name');
        $this->addSql('ALTER TABLE users DROP last_name');
        $this->addSql('ALTER TABLE reset_password_request DROP CONSTRAINT FK_7CE748AA76ED395');
        $this->addSql('DROP TABLE reset_password_request');
        $this->addSql('TRUNCATE logs');
        $this->addSql('ALTER TABLE logs ADD success BOOLEAN NOT NULL');
        $this->addSql('ALTER TABLE logs DROP state');
        $this->addSql('ALTER TABLE logs DROP mailcount');
        $this->addSql('ALTER TABLE logs ALTER message DROP NOT NULL');
        $this->addSql('ALTER TABLE logs ALTER details DROP NOT NULL');
        $this->addSql('DROP INDEX config_pkey');
        $this->addSql('ALTER TABLE config DROP type');
        $this->addSql('ALTER TABLE config RENAME COLUMN key TO name');
        $this->addSql('ALTER TABLE config ADD PRIMARY KEY (name)');
    }
}
