<?php
/* @noinspection PhpUnused */
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*
* @package API
* @internal
*/
final class Version20220422111513 extends AbstractMigration
{
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE protective_gear_l10n DROP FOREIGN KEY FK_5204FE3D706E52B3');
$this->addSql('ALTER TABLE protective_gear_l10n DROP FOREIGN KEY FK_5204FE3D6A2856C7');
$this->addSql('ALTER TABLE protective_gear DROP FOREIGN KEY FK_EA3B186612469DE2');
$this->addSql('ALTER TABLE protective_gear_category_l10n DROP FOREIGN KEY FK_1EA080C4706E52B3');
$this->addSql('ALTER TABLE protective_gear_category_l10n DROP FOREIGN KEY FK_1EA080C46A2856C7');
$this->addSql('DROP TABLE protective_gear');
$this->addSql('DROP TABLE protective_gear_category');
$this->addSql('DROP TABLE protective_gear_category_l10n');
$this->addSql('DROP TABLE protective_gear_l10n');
}
public function getDescription(): string
{
return
"- Introduces protective gear table and localizations.\n" .
"- Introduces protective gear category table and localizations.";
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(
'
CREATE TABLE protective_gear (
id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
category_id INT DEFAULT NULL COMMENT \'Internal ID\',
active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
INDEX IDX_EA3B186612469DE2 (category_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
CREATE TABLE protective_gear_category (
id INT AUTO_INCREMENT NOT NULL COMMENT \'Internal ID\',
created INT NOT NULL COMMENT \'Entity creation date as UNIX timestamp\',
active SMALLINT DEFAULT 1 NOT NULL COMMENT \'Indicator if entity is active\',
last_active_date DATE DEFAULT NULL COMMENT \'Last active date\',
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
CREATE TABLE protective_gear_category_l10n (
language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
name VARCHAR(225) DEFAULT NULL COMMENT \'Protective gear category name in referenced language\',
INDEX IDX_1EA080C482F1BAF4 (language_id),
INDEX IDX_1EA080C4706E52B3 (parent_entity_id),
PRIMARY KEY(parent_entity_id, language_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
CREATE TABLE protective_gear_l10n (
language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
name VARCHAR(225) DEFAULT NULL COMMENT \'Protective gear name in referenced language\',
INDEX IDX_5204FE3D82F1BAF4 (language_id),
INDEX IDX_5204FE3D706E52B3 (parent_entity_id),
PRIMARY KEY(parent_entity_id, language_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
'
);
$this->addSql(
'
ALTER TABLE protective_gear ADD CONSTRAINT FK_EA3B186612469DE2 FOREIGN KEY
(category_id) REFERENCES protective_gear_category (id) ON DELETE SET NULL
'
);
$this->addSql(
'
ALTER TABLE protective_gear_category_l10n ADD CONSTRAINT FK_1EA080C46A2856C7 FOREIGN KEY
(language_id) REFERENCES language (id) ON DELETE CASCADE
'
);
$this->addSql(
'
ALTER TABLE protective_gear_category_l10n ADD CONSTRAINT FK_1EA080C4706E52B3 FOREIGN KEY
(parent_entity_id) REFERENCES protective_gear_category (id) ON DELETE CASCADE
'
);
$this->addSql(
'
ALTER TABLE protective_gear_l10n ADD CONSTRAINT FK_5204FE3D6A2856C7 FOREIGN KEY
(language_id) REFERENCES language (id) ON DELETE CASCADE
'
);
$this->addSql(
'
ALTER TABLE protective_gear_l10n ADD CONSTRAINT FK_5204FE3D706E52B3 FOREIGN KEY
(parent_entity_id) REFERENCES protective_gear (id) ON DELETE CASCADE
'
);
}
}