<?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 Version20241105102636 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("CREATE TABLE `dp_stock_history` (
`id` int NOT NULL AUTO_INCREMENT,
`product_id` int DEFAULT NULL,
`product_variant_id` int DEFAULT NULL,
`level_id` int DEFAULT NULL,
`quantity` int DEFAULT NULL,
`company_id` int DEFAULT NULL,
`created_by` int DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`is_deleted` int NOT NULL DEFAULT '0',
`deleted_by` int DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `product_id` (`product_id`),
KEY `product_variant_id` (`product_variant_id`),
KEY `level_id` (`level_id`),
KEY `created_by` (`created_by`),
KEY `deleted_by` (`deleted_by`),
CONSTRAINT `dp_stock_history_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `dp_products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_stock_history_ibfk_2` FOREIGN KEY (`product_variant_id`) REFERENCES `dp_product_variants` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_stock_history_ibfk_3` FOREIGN KEY (`level_id`) REFERENCES `dp_levels` (`level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_stock_history_ibfk_4` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `dp_stock_history_ibfk_5` FOREIGN KEY (`deleted_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
$this->addSql("CREATE TABLE `tc_stock_history_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` varchar(255) DEFAULT NULL,
`to_data` varchar(255) DEFAULT NULL,
`done_at` datetime NOT NULL,
`done_by` int NOT NULL,
PRIMARY KEY (`id`),
KEY `company_id` (`company_id`),
KEY `user_id` (`user_id`) USING BTREE,
KEY `done_by` (`done_by`),
CONSTRAINT `tc_stock_history_activity_log_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `tc_stock_history_activity_log_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `tc_stock_history_activity_log_ibfk_3` FOREIGN KEY (`done_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS `dp_stock_history`");
$this->addSql("DROP TABLE IF EXISTS `tc_stock_history_activity_log`");
}
}