migrations/Version20240731105009.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 Version20240731105009 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_downtime_planning` (
  18.         `id` int NOT NULL AUTO_INCREMENT,
  19.         `level_id` int NOT NULL,
  20.         `company_id` int NOT NULL,
  21.         `downtime_date` date NOT NULL,
  22.         `start_time` time NOT NULL,
  23.         `end_time` time NOT NULL,
  24.         `comment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
  25.         `notify_days` int NOT NULL DEFAULT '0',
  26.         `send_mail` int NOT NULL DEFAULT '0',
  27.         `is_deleted` int NOT NULL DEFAULT '0',
  28.         `created_by` int NOT NULL,
  29.         `created_at` datetime NOT NULL,
  30.         `updated_by` int DEFAULT NULL,
  31.         `updated_at` datetime DEFAULT NULL,
  32.         `deleted_at` datetime DEFAULT NULL,
  33.         PRIMARY KEY (`id`),
  34.         KEY `level_id` (`level_id`),
  35.         KEY `created_by` (`created_by`),
  36.         KEY `updated_by` (`updated_by`),
  37.         KEY `company_id` (`company_id`),
  38.         CONSTRAINT `dp_downtime_planning_ibfk_1` FOREIGN KEY (`level_id`) REFERENCES `dp_levels` (`level_id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  39.         CONSTRAINT `dp_downtime_planning_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  40.         CONSTRAINT `dp_downtime_planning_ibfk_3` FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  41.         CONSTRAINT `dp_downtime_planning_ibfk_4` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  42.         ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
  43.             );
  44.         $this->addSql("CREATE TABLE `dp_column_settings` (
  45.             `id` int NOT NULL AUTO_INCREMENT,
  46.             `table_name` varchar(255) NOT NULL,
  47.             `company_id` int NOT NULL,
  48.             `column_key` varchar(255) NOT NULL,
  49.             `sort_order` int NOT NULL,
  50.             `created_by` int NOT NULL,
  51.             `created_at` int NOT NULL,
  52.             PRIMARY KEY (`id`),
  53.             KEY `created_by` (`created_by`),
  54.             KEY `company_id` (`company_id`),
  55.             CONSTRAINT `dp_column_settings_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  56.             CONSTRAINT `dp_column_settings_ibfk_2` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  57.             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
  58.         );
  59.         $this->addSql("ALTER TABLE `tc_board_cards` ADD `prefix` varchar(255) NULL AFTER `ref_id`");
  60.         $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`");
  61.         $this->addSql("ALTER TABLE `tc_stock_quantity` ADD FOREIGN KEY (`updated_by`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT");
  62.         $this->addSql("ALTER TABLE `company_settings` ADD `card_refid_prefix` varchar(50) NULL AFTER `shift_end_delay_time`");
  63.         $this->addSql("ALTER TABLE `company_settings` ADD `card_refid_starts_from` INT NOT NULL AFTER `card_refid_prefix`");
  64.     }
  65.     public function down(Schema $schema): void
  66.     {
  67.         $this->addSql('DROP TABLE dp_downtime_planning');
  68.         $this->addSql('DROP TABLE dp_column_settings');
  69.         $this->addSql("ALTER TABLE `tc_board_cards` DROP COLUMN `prefix`");
  70.         $this->addSql("ALTER TABLE `tc_stock_quantity` DROP FOREIGN KEY `tc_stock_quantity_ibfk_6`");
  71.         $this->addSql("ALTER TABLE `tc_stock_quantity` DROP COLUMN `updated_by`");
  72.         $this->addSql("ALTER TABLE `tc_stock_quantity` DROP COLUMN `updated_at`");
  73.         $this->addSql("ALTER TABLE `company_settings` DROP COLUMN `card_refid_starts_from`");
  74.         $this->addSql("ALTER TABLE `company_settings` DROP COLUMN `card_refid_prefix`");
  75.     }
  76. }