<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use App\Entity\Target;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Modified migration that populates the tag and tag_scan tables
*/
final class Version20230815223228 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 tag (type INT NOT NULL, label VARCHAR(50) NOT NULL, short_label VARCHAR(5) NOT NULL, UNIQUE INDEX UNIQ_389B783EA750E8 (label), UNIQUE INDEX UNIQ_389B7838EA2F0ED (short_label), PRIMARY KEY(type)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tag_scan (tag_type INT NOT NULL, scan_id VARCHAR(32) NOT NULL, INDEX IDX_2ABC0C1862D1E89F (tag_type), INDEX IDX_2ABC0C182827AAD3 (scan_id), PRIMARY KEY(tag_type, scan_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE tag_scan ADD CONSTRAINT FK_2ABC0C1862D1E89F FOREIGN KEY (tag_type) REFERENCES tag (type)');
$this->addSql('ALTER TABLE tag_scan ADD CONSTRAINT FK_2ABC0C182827AAD3 FOREIGN KEY (scan_id) REFERENCES scans (id)');
// Custom SQL: Insert rows into the tag table
$this->addSql("INSERT INTO tag (type, label, short_label) VALUES (1, 'Deep Linking', 'DL')");
$this->addSql("INSERT INTO tag (type, label, short_label) VALUES (2, 'Homepage', 'HP')");
$this->addSql("INSERT INTO tag (type, label, short_label) VALUES (3, 'Malicious', 'ML')");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE tag_scan DROP FOREIGN KEY FK_2ABC0C1862D1E89F');
$this->addSql('DROP TABLE tag');
$this->addSql('DROP TABLE tag_scan');
}
}