<?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 Version20241025064805 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("CREATE TABLE IF NOT EXISTS `dp_downtime_opunit` (
`id` int NOT NULL AUTO_INCREMENT,
`company_id` int NOT NULL,
`downtime_planing_id` int NOT NULL DEFAULT '0',
`level_id` int NOT NULL DEFAULT '0',
`opunit_id` int NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`),
KEY `downtime_planing_id` (`downtime_planing_id`),
KEY `level_id` (`level_id`),
KEY `opunit_id` (`opunit_id`),
CONSTRAINT `dp_downtime_opunit_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_downtime_opunit_ibfk_2` FOREIGN KEY (`downtime_planing_id`) REFERENCES `dp_downtime_planning` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_downtime_opunit_ibfk_3` FOREIGN KEY (`level_id`) REFERENCES `dp_levels` (`level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_downtime_opunit_ibfk_4` FOREIGN KEY (`opunit_id`) REFERENCES `dp_operational_unit` (`op_ut_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
);");
$this->addSql("ALTER TABLE `dp_downtime_planning` DROP FOREIGN KEY `dp_downtime_planning_ibfk_1`;");
$this->addSql("ALTER TABLE `dp_downtime_planning` CHANGE `level_id` `level_id` INT NULL DEFAULT NULL;");
$this->addSql("ALTER TABLE `dp_downtime_planning` ADD FOREIGN KEY (`level_id`) REFERENCES `dp_levels`(`level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS `dp_downtime_opunit`");
$this->addSql("ALTER TABLE `dp_downtime_planning` DROP FOREIGN KEY `dp_downtime_planning_ibfk_1`;");
$this->addSql("ALTER TABLE `dp_downtime_planning` CHANGE `level_id` `level_id` INT NOT NULL;");
$this->addSql("ALTER TABLE `dp_downtime_opunit` DROP FOREIGN KEY `dp_downtime_opunit_ibfk_3`;");
$this->addSql("ALTER TABLE `dp_downtime_opunit` CHANGE `level_id` `level_id` INT NOT NULL;");
$this->addSql("ALTER TABLE `dp_downtime_opunit` DROP FOREIGN KEY `dp_downtime_opunit_ibfk_4`;");
$this->addSql("ALTER TABLE `dp_downtime_opunit` CHANGE `opunit_id` `opunit_id` INT NOT NULL;");
}
}