<?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 Version20230503081202 extends AbstractMigration
{
public function getDescription(): string
{
return
"- Introduces OIM status 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 oim_status (
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\',
internal_status_id VARCHAR(16) NOT NULL COMMENT \'Internal status ID\',
INDEX IDX_6717E8FFE330F8D6 (internal_status_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
'
);
$this->addSql(
'
CREATE TABLE oim_status_l10n (
parent_entity_id INT NOT NULL COMMENT \'Internal ID\',
language_id VARCHAR(2) NOT NULL COMMENT \'Language code in lower case (ISO 639-1)\',
name VARCHAR(225) DEFAULT NULL COMMENT \'Status name in referenced language\',
INDEX IDX_B70EF479706E52B3 (parent_entity_id),
INDEX IDX_B70EF47982F1BAF4 (language_id),
PRIMARY KEY(parent_entity_id, language_id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
'
);
$this->addSql(
'
ALTER TABLE oim_status ADD CONSTRAINT FK_6717E8FFE330F8D6 FOREIGN KEY
(internal_status_id) REFERENCES oim_internal_status (id);
'
);
$this->addSql(
'
ALTER TABLE oim_status_l10n ADD CONSTRAINT FK_B70EF479706E52B3 FOREIGN KEY
(parent_entity_id) REFERENCES oim_status (id) ON DELETE CASCADE;
'
);
$this->addSql(
'
ALTER TABLE oim_status_l10n ADD CONSTRAINT FK_B70EF47982F1BAF4 FOREIGN KEY
(language_id) REFERENCES language (id) ON DELETE CASCADE;
'
);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE oim_status_l10n DROP FOREIGN KEY FK_B70EF479706E52B3');
$this->addSql('ALTER TABLE oim_status_l10n DROP FOREIGN KEY FK_B70EF47982F1BAF4');
$this->addSql('DROP TABLE oim_status_l10n');
$this->addSql('ALTER TABLE oim_status DROP FOREIGN KEY FK_6717E8FFE330F8D6');
$this->addSql('DROP TABLE oim_status');
}
}