migrations/Version20241105102636.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20241105102636 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("CREATE TABLE `dp_stock_history` (
  18.             `id` int NOT NULL AUTO_INCREMENT,
  19.             `product_id` int DEFAULT NULL,
  20.             `product_variant_id` int DEFAULT NULL,
  21.             `level_id` int DEFAULT NULL,
  22.             `quantity` int DEFAULT NULL,
  23.             `company_id` int DEFAULT NULL,
  24.             `created_by` int DEFAULT NULL,
  25.             `created_at` datetime DEFAULT NULL,
  26.             `is_deleted` int NOT NULL DEFAULT '0',
  27.             `deleted_by` int DEFAULT NULL,
  28.             `deleted_at` datetime DEFAULT NULL,
  29.             PRIMARY KEY (`id`),
  30.             KEY `product_id` (`product_id`),
  31.             KEY `product_variant_id` (`product_variant_id`),
  32.             KEY `level_id` (`level_id`),
  33.             KEY `created_by` (`created_by`),
  34.             KEY `deleted_by` (`deleted_by`),
  35.             CONSTRAINT `dp_stock_history_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `dp_products` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  36.             CONSTRAINT `dp_stock_history_ibfk_2` FOREIGN KEY (`product_variant_id`) REFERENCES `dp_product_variants` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  37.             CONSTRAINT `dp_stock_history_ibfk_3` FOREIGN KEY (`level_id`) REFERENCES `dp_levels` (`level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  38.             CONSTRAINT `dp_stock_history_ibfk_4` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  39.             CONSTRAINT `dp_stock_history_ibfk_5` FOREIGN KEY (`deleted_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  40.           ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
  41.         $this->addSql("CREATE TABLE `tc_stock_history_activity_log` (
  42.             `id` int NOT NULL AUTO_INCREMENT,
  43.             `company_id` int NOT NULL,
  44.             `user_id` int NOT NULL,
  45.             `action` varchar(255) NOT NULL,
  46.             `from_data` varchar(255) DEFAULT NULL,
  47.             `to_data` varchar(255) DEFAULT NULL,
  48.             `done_at` datetime NOT NULL,
  49.             `done_by` int NOT NULL,
  50.             PRIMARY KEY (`id`),
  51.             KEY `company_id` (`company_id`),
  52.             KEY `user_id` (`user_id`) USING BTREE,
  53.             KEY `done_by` (`done_by`),
  54.             CONSTRAINT `tc_stock_history_activity_log_ibfk_1` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  55.             CONSTRAINT `tc_stock_history_activity_log_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  56.             CONSTRAINT `tc_stock_history_activity_log_ibfk_3` FOREIGN KEY (`done_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  57.           ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci");
  58.     }
  59.     public function down(Schema $schema): void
  60.     {
  61.         $this->addSql("DROP TABLE IF EXISTS `dp_stock_history`");
  62.         $this->addSql("DROP TABLE IF EXISTS `tc_stock_history_activity_log`");
  63.     }
  64. }