<?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 Version20240906111850 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("CREATE TABLE `notification_log` (
`id` int NOT NULL AUTO_INCREMENT,
`notification_setting_id` int NOT NULL,
`workorder_id` int DEFAULT NULL,
`shipping_date` date DEFAULT NULL,
`start_date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`action` varchar(255) NOT NULL,
`is_deleted` int NOT NULL DEFAULT '0',
`created_at` datetime NOT NULL,
`created_by` int NOT NULL,
PRIMARY KEY (`id`),
KEY `created_by` (`created_by`),
KEY `notification_setting_id` (`notification_setting_id`),
KEY `notification_log_ibfk_3` (`workorder_id`),
CONSTRAINT `notification_log_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `notification_log_ibfk_2` FOREIGN KEY (`notification_setting_id`) REFERENCES `company_notification_settings` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `notification_log_ibfk_3` FOREIGN KEY (`workorder_id`) REFERENCES `dp_workorder` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
)");
$this->addSql("CREATE TABLE `dp_user_read_notification` (
`id` int NOT NULL AUTO_INCREMENT,
`notification_setting_id` int NOT NULL,
`company_id` int NOT NULL,
`user_id` int NOT NULL,
`notification_log_id` int DEFAULT NULL,
`is_read` int NOT NULL DEFAULT '0',
`created_by` int NOT NULL,
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`),
KEY `user_id` (`user_id`),
KEY `dp_user_read_notification_ibfk_1` (`notification_setting_id`),
KEY `dp_user_read_notification_ibfk_4` (`notification_log_id`),
CONSTRAINT `dp_user_read_notification_ibfk_1` FOREIGN KEY (`notification_setting_id`) REFERENCES `company_notification_settings` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_user_read_notification_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_user_read_notification_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_user_read_notification_ibfk_4` FOREIGN KEY (`notification_log_id`) REFERENCES `notification_log` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
)");
$this->addSql("ALTER TABLE `dp_workorder` ADD `production_status` ENUM('pending','in_progress','completed') NOT NULL DEFAULT 'pending' AFTER `work_order_status`");
$this->addSql("INSERT INTO `company_notification_settings` (`id`, `company_id`, `notification_type`, `notify_date`, `created_at`) VALUES
(1, 1, 'shipping_due_date', 0, '2024-08-30 11:13:33')");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS `notification_log`");
$this->addSql("DROP TABLE IF EXISTS `dp_user_read_notification`");
$this->addSql("ALTER TABLE `dp_workorder` DROP COLUMN `production_status`");
}
}