<?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 Version20240826073359 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("CREATE TABLE tc_product_activity_log (
id int NOT NULL AUTO_INCREMENT,
company_id int NOT NULL,
user_id int NOT NULL,
action varchar(255) NOT NULL,
from_data mediumtext NOT NULL,
to_data mediumtext NOT NULL,
done_at datetime NOT NULL,
done_by int NOT NULL,
PRIMARY KEY (id),
KEY company_id (company_id),
KEY user_id (user_id),
KEY done_by (done_by),
CONSTRAINT tc_product_activity_log_ibfk_1 FOREIGN KEY (company_id) REFERENCES company (id) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT tc_product_activity_log_ibfk_2 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT tc_product_activity_log_ibfk_3 FOREIGN KEY (done_by) REFERENCES user (id) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
");
$this->addSql("ALTER TABLE `tc_production_history` ADD `is_deleted` INT NOT NULL DEFAULT '0' AFTER `scrap_reason_id`, ADD `deleted_at` DATETIME NULL DEFAULT NULL AFTER `is_deleted`");
$this->addSql("ALTER TABLE `dp_workorder_allocated_quantity` ADD `is_deleted` INT NOT NULL DEFAULT '0' AFTER `updated_at`, ADD `deleted_at` DATETIME NULL AFTER `is_deleted`, ADD `deleted_by` INT NULL AFTER `deleted_at`");
$this->addSql("ALTER TABLE `dp_workorder_allocated_quantity` ADD FOREIGN KEY (`deleted_by`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT");
$this->addSql("ALTER TABLE `tc_production_history` ADD `deleted_by` INT NULL AFTER `deleted_at`");
$this->addSql("ALTER TABLE `tc_production_history` ADD FOREIGN KEY (`deleted_by`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT");
$this->addSql("ALTER TABLE `dp_workorder` ADD `is_deleted` INT NOT NULL DEFAULT '0' AFTER `updated_at`, ADD `deleted_at` INT NULL AFTER `is_deleted`, ADD `deleted_by` INT NULL AFTER `deleted_at`");
$this->addSql("ALTER TABLE `dp_workorder` ADD FOREIGN KEY (`deleted_by`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT");
$this->addSql("ALTER TABLE `dp_workorder` CHANGE `deleted_at` `deleted_at` DATETIME NULL DEFAULT NULL");
$this->addSql("ALTER TABLE `dp_workorder` ADD `assy_ship_date` DATE NULL AFTER `assy_planned_end_date`, ADD `smt_ship_date` DATE NULL AFTER `assy_ship_date`");
$this->addSql("ALTER TABLE `dp_workorder` ADD `import_id` INT NULL AFTER `work_order_status`");
$this->addSql("ALTER TABLE `dp_workorder` ADD CONSTRAINT `dp_workorder_ibfk_8` FOREIGN KEY (`import_id`) REFERENCES `tc_imports`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT");
}
public function down(Schema $schema): void
{
$this->addSql("ALTER TABLE `dp_workorder` DROP FOREIGN KEY `dp_workorder_ibfk_8`");
$this->addSql("ALTER TABLE `dp_workorder` DROP COLUMN `import_id`");
$this->addSql("ALTER TABLE `dp_workorder` DROP FOREIGN KEY `dp_workorder_ibfk_7`");
$this->addSql("ALTER TABLE `dp_workorder` DROP COLUMN `deleted_by`");
$this->addSql("ALTER TABLE `dp_workorder` DROP COLUMN `deleted_at`");
$this->addSql("ALTER TABLE `dp_workorder` DROP COLUMN `is_deleted`");
$this->addSql("ALTER TABLE `dp_workorder` DROP COLUMN `assy_ship_date`");
$this->addSql("ALTER TABLE `dp_workorder` DROP COLUMN `smt_ship_date`");
$this->addSql("ALTER TABLE `tc_production_history` DROP FOREIGN KEY `tc_production_history_ibfk_10`");
$this->addSql("ALTER TABLE `tc_production_history` DROP COLUMN `deleted_by`");
$this->addSql("ALTER TABLE `tc_production_history` DROP COLUMN `deleted_at`");
$this->addSql("ALTER TABLE `tc_production_history` DROP COLUMN `is_deleted`");
$this->addSql("ALTER TABLE `dp_workorder_allocated_quantity` DROP FOREIGN KEY `dp_workorder_allocated_quantity_ibfk_8`");
$this->addSql("ALTER TABLE `dp_workorder_allocated_quantity` DROP COLUMN `deleted_by`");
$this->addSql("ALTER TABLE `dp_workorder_allocated_quantity` DROP COLUMN `deleted_at`");
$this->addSql("ALTER TABLE `dp_workorder_allocated_quantity` DROP COLUMN `is_deleted`");
$this->addSql("DROP TABLE IF EXISTS `tc_product_activity_log`");
}
}