<?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 Version20240305191331 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 alerts_archive (id INT NOT NULL, alert_id VARCHAR(255) NOT NULL, history_id VARCHAR(255) NOT NULL, trigger_type_id VARCHAR(255) NOT NULL, alert_name VARCHAR(255) NOT NULL, trigger_metadata VARCHAR(255) NOT NULL, event_datetime DATE NOT NULL, location LONGTEXT NOT NULL COMMENT \'(DC2Type:simple_array)\', scan_id VARCHAR(32) NOT NULL, alert_details_url VARCHAR(255) NOT NULL, project_name VARCHAR(255) NOT NULL, project_id VARCHAR(255) NOT NULL, INDEX IDX_B0853D6D2827AAD3 (scan_id), UNIQUE INDEX uk_geoedge_alert_history_archive_id (history_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE security_incident_urls_archive (id INT NOT NULL, alert_id INT NOT NULL, url VARCHAR(255) NOT NULL, INDEX IDX_68193993035F72 (alert_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE alerts_archive ADD CONSTRAINT FK_B0853D6D2827AAD3 FOREIGN KEY (scan_id) REFERENCES scans_archive (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE security_incident_urls_archive ADD CONSTRAINT FK_68193993035F72 FOREIGN KEY (alert_id) REFERENCES alerts_archive (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE alerts DROP FOREIGN KEY FK_F77AC06B2827AAD3');
$this->addSql('ALTER TABLE alerts ADD CONSTRAINT FK_F77AC06B2827AAD3 FOREIGN KEY (scan_id) REFERENCES scans (id) ON DELETE CASCADE ON UPDATE CASCADE');
$this->addSql('ALTER TABLE security_incident_urls DROP FOREIGN KEY FK_4971FE0093035F72');
$this->addSql('ALTER TABLE security_incident_urls ADD CONSTRAINT FK_4971FE0093035F72 FOREIGN KEY (alert_id) REFERENCES alerts (id) ON DELETE CASCADE ON UPDATE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE alerts_archive DROP FOREIGN KEY FK_B0853D6D2827AAD3');
$this->addSql('ALTER TABLE security_incident_urls_archive DROP FOREIGN KEY FK_68193993035F72');
$this->addSql('DROP TABLE alerts_archive');
$this->addSql('DROP TABLE security_incident_urls_archive');
$this->addSql('ALTER TABLE alerts DROP FOREIGN KEY FK_F77AC06B2827AAD3');
$this->addSql('ALTER TABLE alerts ADD CONSTRAINT FK_F77AC06B2827AAD3 FOREIGN KEY (scan_id) REFERENCES scans (id) ON UPDATE CASCADE ON DELETE CASCADE');
$this->addSql('ALTER TABLE security_incident_urls DROP FOREIGN KEY FK_4971FE0093035F72');
$this->addSql('ALTER TABLE security_incident_urls ADD CONSTRAINT FK_4971FE0093035F72 FOREIGN KEY (alert_id) REFERENCES alerts (id)');
}
}