<?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 Version20260206230000 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Create etat_lieux_comment table and add fields to etat_lieux';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql("CREATE TABLE etat_lieux_comment (id SERIAL NOT NULL, etat_lieux_id INT NOT NULL, content TEXT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))");
        $this->addSql("CREATE INDEX IDX_ETAT_LIEUX_COMMENT ON etat_lieux_comment (etat_lieux_id)");
        $this->addSql("COMMENT ON COLUMN etat_lieux_comment.created_at IS '(DC2Type:datetime_immutable)'");
        $this->addSql('ALTER TABLE etat_lieux_comment ADD CONSTRAINT FK_ETAT_LIEUX_COMMENT FOREIGN KEY (etat_lieux_id) REFERENCES etat_lieux (id) NOT DEFERRABLE INITIALLY IMMEDIATE');

        $this->addSql('ALTER TABLE etat_lieux ADD sign_id_delivery VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD sign_id_customer VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD etat_lieux_unsign_file_name VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD etat_lieux_unsign_file_size INT DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD etat_lieux_sign_file_name VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD etat_lieux_sign_file_size INT DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD etat_lieux_audit_file_name VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD etat_lieux_audit_file_size INT DEFAULT NULL');
        $this->addSql('ALTER TABLE etat_lieux ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
        $this->addSql("COMMENT ON COLUMN etat_lieux.updated_at IS '(DC2Type:datetime_immutable)'");
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE etat_lieux_comment DROP FOREIGN KEY FK_ETAT_LIEUX_COMMENT');
        $this->addSql('DROP TABLE etat_lieux_comment');
        
        $this->addSql('ALTER TABLE etat_lieux DROP sign_id_delivery');
        $this->addSql('ALTER TABLE etat_lieux DROP sign_id_customer');
        $this->addSql('ALTER TABLE etat_lieux DROP etat_lieux_unsign_file_name');
        $this->addSql('ALTER TABLE etat_lieux DROP etat_lieux_unsign_file_size');
        $this->addSql('ALTER TABLE etat_lieux DROP etat_lieux_sign_file_name');
        $this->addSql('ALTER TABLE etat_lieux DROP etat_lieux_sign_file_size');
        $this->addSql('ALTER TABLE etat_lieux DROP etat_lieux_audit_file_name');
        $this->addSql('ALTER TABLE etat_lieux DROP etat_lieux_audit_file_size');
        $this->addSql('ALTER TABLE etat_lieux DROP updated_at');
    }
}
