<?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 Version20260407085302 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 action_log (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, action VARCHAR(50) NOT NULL, entity_id INT DEFAULT NULL, entity_type VARCHAR(50) DEFAULT NULL, message TEXT NOT NULL, context TEXT DEFAULT NULL, severity VARCHAR(20) NOT NULL, previous_state VARCHAR(50) DEFAULT NULL, new_state VARCHAR(50) DEFAULT NULL, success BOOLEAN NOT NULL, error_message TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, customer_id INT DEFAULT NULL, PRIMARY KEY (id))');
        $this->addSql('CREATE INDEX idx_action_log_customer ON action_log (customer_id)');
        $this->addSql('CREATE INDEX idx_action_log_action ON action_log (action)');
        $this->addSql('CREATE INDEX idx_action_log_created ON action_log (created_at)');
        $this->addSql('ALTER TABLE action_log ADD CONSTRAINT FK_B2C5F6859395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE SET NULL NOT DEFERRABLE');
        $this->addSql('ALTER TABLE advert_line ADD type VARCHAR(30) DEFAULT NULL');
        $this->addSql('ALTER TABLE advert_line ADD service_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE devis_line ADD type VARCHAR(30) DEFAULT NULL');
        $this->addSql('ALTER TABLE devis_line ADD service_id INT DEFAULT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE action_log DROP CONSTRAINT FK_B2C5F6859395C3F3');
        $this->addSql('DROP TABLE action_log');
        $this->addSql('ALTER TABLE advert_line DROP type');
        $this->addSql('ALTER TABLE advert_line DROP service_id');
        $this->addSql('ALTER TABLE devis_line DROP type');
        $this->addSql('ALTER TABLE devis_line DROP service_id');
    }
}
