<?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 Version20260330205802 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('CREATE TABLE attestation (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, reference VARCHAR(64) NOT NULL, type VARCHAR(50) NOT NULL, ip VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, hmac VARCHAR(128) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, email_tracking_id INT DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_326EC63FAEA34913 ON attestation (reference)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_326EC63F6BC5D709 ON attestation (email_tracking_id)');
        $this->addSql('ALTER TABLE attestation ADD CONSTRAINT FK_326EC63F6BC5D709 FOREIGN KEY (email_tracking_id) REFERENCES email_tracking (id) ON DELETE SET NULL NOT DEFERRABLE');
        $this->addSql('ALTER TABLE email_tracking ADD attachments JSON DEFAULT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE attestation DROP CONSTRAINT FK_326EC63F6BC5D709');
        $this->addSql('DROP TABLE attestation');
        $this->addSql('ALTER TABLE email_tracking DROP attachments');
    }
}
