<?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 Version20240731105009 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("CREATE TABLE `dp_downtime_planning` (
`id` int NOT NULL AUTO_INCREMENT,
`level_id` int NOT NULL,
`company_id` int NOT NULL,
`downtime_date` date NOT NULL,
`start_time` time NOT NULL,
`end_time` time NOT NULL,
`comment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
`notify_days` int NOT NULL DEFAULT '0',
`send_mail` int NOT NULL DEFAULT '0',
`is_deleted` int NOT NULL DEFAULT '0',
`created_by` int NOT NULL,
`created_at` datetime NOT NULL,
`updated_by` int DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `level_id` (`level_id`),
KEY `created_by` (`created_by`),
KEY `updated_by` (`updated_by`),
KEY `company_id` (`company_id`),
CONSTRAINT `dp_downtime_planning_ibfk_1` FOREIGN KEY (`level_id`) REFERENCES `dp_levels` (`level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_downtime_planning_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_downtime_planning_ibfk_3` FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_downtime_planning_ibfk_4` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
);
$this->addSql("CREATE TABLE `dp_column_settings` (
`id` int NOT NULL AUTO_INCREMENT,
`table_name` varchar(255) NOT NULL,
`company_id` int NOT NULL,
`column_key` varchar(255) NOT NULL,
`sort_order` int NOT NULL,
`created_by` int NOT NULL,
`created_at` int NOT NULL,
PRIMARY KEY (`id`),
KEY `created_by` (`created_by`),
KEY `company_id` (`company_id`),
CONSTRAINT `dp_column_settings_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_column_settings_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
);
$this->addSql("ALTER TABLE `tc_board_cards` ADD `prefix` varchar(255) NULL AFTER `ref_id`");
$this->addSql("ALTER TABLE `tc_stock_quantity` ADD `updated_at` DATETIME NULL DEFAULT NULL AFTER `created_by`, ADD `updated_by` INT NULL DEFAULT NULL AFTER `updated_at`");
$this->addSql("ALTER TABLE `tc_stock_quantity` ADD FOREIGN KEY (`updated_by`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT");
$this->addSql("ALTER TABLE `company_settings` ADD `card_refid_prefix` varchar(50) NULL AFTER `shift_end_delay_time`");
$this->addSql("ALTER TABLE `company_settings` ADD `card_refid_starts_from` INT NOT NULL AFTER `card_refid_prefix`");
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE dp_downtime_planning');
$this->addSql('DROP TABLE dp_column_settings');
$this->addSql("ALTER TABLE `tc_board_cards` DROP COLUMN `prefix`");
$this->addSql("ALTER TABLE `tc_stock_quantity` DROP FOREIGN KEY `tc_stock_quantity_ibfk_6`");
$this->addSql("ALTER TABLE `tc_stock_quantity` DROP COLUMN `updated_by`");
$this->addSql("ALTER TABLE `tc_stock_quantity` DROP COLUMN `updated_at`");
$this->addSql("ALTER TABLE `company_settings` DROP COLUMN `card_refid_starts_from`");
$this->addSql("ALTER TABLE `company_settings` DROP COLUMN `card_refid_prefix`");
}
}