migrations/Version20260817172223.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 Version20260817172223 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE material_request (id INT AUTO_INCREMENT NOT NULL, task_execution_id INT NOT NULL, requester_id INT NOT NULL, reviewer_id INT DEFAULT NULL, status ENUM(\'draft\', \'submitted\', \'ordered\', \'partially_ordered\', \'rejected\') DEFAULT \'draft\' NOT NULL, submitted_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', reviewed_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_8A0D54309F837169 (task_execution_id), INDEX IDX_8A0D5430ED442CF4 (requester_id), INDEX IDX_8A0D543070574616 (reviewer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE material_request_documents (id INT AUTO_INCREMENT NOT NULL, material_request_id INT NOT NULL, item_group_id INT NOT NULL, name VARCHAR(255) NOT NULL, file_name VARCHAR(255) NOT NULL, file_path VARCHAR(255) NOT NULL, status ENUM(\'pending\', \'ordered\', \'partially_ordered\', \'rejected\') DEFAULT \'pending\' NOT NULL, review_note LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_1F02E1BAE24CC4C7 (material_request_id), INDEX IDX_1F02E1BA9259118C (item_group_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE project_order_task_fulfillment_date_revisions (id INT AUTO_INCREMENT NOT NULL, project_order_task_fulfillment_id INT NOT NULL, start_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', end_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', reason VARCHAR(1000) DEFAULT NULL, reason_category ENUM(\'supply\', \'personnel\', \'weather\', \'scope_change\', \'other\') DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_2968491DC55C4AC2 (project_order_task_fulfillment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE project_order_task_fulfillment_messages (id INT AUTO_INCREMENT NOT NULL, execution_id INT NOT NULL, sender_side ENUM(\'owner\', \'executor\') NOT NULL, sender_name VARCHAR(191) NOT NULL, body LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_E763A8DC57125544 (execution_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE stock_item_groups (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(64) NOT NULL, description VARCHAR(64) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('ALTER TABLE material_request ADD CONSTRAINT FK_8A0D54309F837169 FOREIGN KEY (task_execution_id) REFERENCES project_order_task_fulfillment (id) ON DELETE CASCADE');
  24.         $this->addSql('ALTER TABLE material_request ADD CONSTRAINT FK_8A0D5430ED442CF4 FOREIGN KEY (requester_id) REFERENCES worker_activities (id)');
  25.         $this->addSql('ALTER TABLE material_request ADD CONSTRAINT FK_8A0D543070574616 FOREIGN KEY (reviewer_id) REFERENCES worker_activities (id)');
  26.         $this->addSql('ALTER TABLE material_request_documents ADD CONSTRAINT FK_1F02E1BAE24CC4C7 FOREIGN KEY (material_request_id) REFERENCES material_request (id) ON DELETE CASCADE');
  27.         $this->addSql('ALTER TABLE material_request_documents ADD CONSTRAINT FK_1F02E1BA9259118C FOREIGN KEY (item_group_id) REFERENCES item_groups (id)');
  28.         $this->addSql('ALTER TABLE project_order_task_fulfillment_date_revisions ADD CONSTRAINT FK_2968491DC55C4AC2 FOREIGN KEY (project_order_task_fulfillment_id) REFERENCES project_order_task_fulfillment (id) ON DELETE CASCADE');
  29.         $this->addSql('ALTER TABLE project_order_task_fulfillment_messages ADD CONSTRAINT FK_E763A8DC57125544 FOREIGN KEY (execution_id) REFERENCES project_order_task_fulfillment (id) ON DELETE CASCADE');
  30.         $this->addSql('ALTER TABLE access_modules CHANGE access_module_role access_module_role ENUM(\'intern\', \'extern\') DEFAULT NULL');
  31.         $this->addSql('ALTER TABLE branches ADD responsible_id INT DEFAULT NULL');
  32.         $this->addSql('ALTER TABLE branches ADD CONSTRAINT FK_D760D16F602AD315 FOREIGN KEY (responsible_id) REFERENCES worker_activities (id) ON DELETE SET NULL');
  33.         $this->addSql('CREATE INDEX IDX_D760D16F602AD315 ON branches (responsible_id)');
  34.         $this->addSql('ALTER TABLE calculation_permissions CHANGE type type ENUM(\'total\', \'average\', \'profit\', \'margin\', \'detail_report\') NOT NULL');
  35.         $this->addSql('ALTER TABLE project_order_task_fulfillment ADD status ENUM(\'draft\', \'published\') DEFAULT \'draft\' NOT NULL, ADD published_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD accepted_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD declined_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD decline_reason_category ENUM(\'supply\', \'personnel\', \'weather\', \'scope_change\', \'other\') DEFAULT NULL, ADD decline_reason VARCHAR(1000) DEFAULT NULL, ADD owner_last_read_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD executor_last_read_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', CHANGE reason_id reason_id INT DEFAULT NULL, CHANGE execution_scope execution_scope ENUM(\'internal\', \'external\') DEFAULT NULL, CHANGE execution_work_nature execution_work_nature ENUM(\'support\', \'service\', \'production\') DEFAULT NULL');
  36.         $this->addSql('ALTER TABLE project_order_task_jobs ADD note LONGTEXT DEFAULT NULL');
  37.         $this->addSql('ALTER TABLE projects CHANGE type type ENUM(\'project\', \'daily_work\') DEFAULT \'project\'');
  38.         $this->addSql('ALTER TABLE purchase_request_histories CHANGE sender_mode sender_mode ENUM(\'approver\', \'requester\') DEFAULT NULL');
  39.         $this->addSql('ALTER TABLE purchase_request_status CHANGE status status ENUM(\'pending\', \'approved\', \'rejected\', \'delivered\') NOT NULL');
  40.         $this->addSql('ALTER TABLE stock_transactions CHANGE transaction_type transaction_type ENUM(\'in\', \'out\', \'move\') NOT NULL');
  41.         $this->addSql('CREATE UNIQUE INDEX UNIQ_10F47AF1E16C6B94 ON task_fulfillment_reasons (alias)');
  42.         $this->addSql('ALTER TABLE todo_notifications CHANGE status status ENUM(\'pending\', \'accepted\', \'in_process\', \'awaiting_confirmation\', \'completed\', \'rejected\') DEFAULT NULL, CHANGE type type ENUM(\'status\', \'comment\', \'new_todo\', \'case_closed\') DEFAULT \'status\' NOT NULL');
  43.         $this->addSql('ALTER TABLE todos CHANGE priority priority ENUM(\'low\', \'medium\', \'high\', \'critical\') NOT NULL, CHANGE type type ENUM(\'bug\', \'improvement\', \'suggestion\') NOT NULL, CHANGE status status ENUM(\'pending\', \'accepted\', \'in_process\', \'awaiting_confirmation\', \'completed\', \'rejected\') NOT NULL, CHANGE ai_status ai_status ENUM(\'queued\', \'in_progress\', \'done\', \'failed\') DEFAULT NULL');
  44.         $this->addSql('ALTER TABLE vendor CHANGE vendor_type vendor_type ENUM(\'company\', \'freelancer\') DEFAULT NULL, CHANGE vendor_status vendor_status ENUM(\'active\', \'inactive\') DEFAULT \'active\' NOT NULL');
  45.         $this->addSql('ALTER TABLE vendor_contact_persons ADD user_id INT DEFAULT NULL');
  46.         $this->addSql('ALTER TABLE vendor_contact_persons ADD CONSTRAINT FK_63C3ABEAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL');
  47.         $this->addSql('CREATE INDEX IDX_63C3ABEAA76ED395 ON vendor_contact_persons (user_id)');
  48.         $this->addSql('DROP INDEX unique_personal_id ON worker');
  49.         $this->addSql('CREATE UNIQUE INDEX unique_personal_id ON worker (personal_id)');
  50.         $this->addSql('ALTER TABLE works_plan_revisions CHANGE status status ENUM(\'requested\', \'granted\', \'denied\', \'submitted\', \'approved\', \'rejected\', \'withdrawn\') NOT NULL');
  51.     }
  52.     public function down(Schema $schema): void
  53.     {
  54.         // this down() migration is auto-generated, please modify it to your needs
  55.         $this->addSql('ALTER TABLE material_request DROP FOREIGN KEY FK_8A0D54309F837169');
  56.         $this->addSql('ALTER TABLE material_request DROP FOREIGN KEY FK_8A0D5430ED442CF4');
  57.         $this->addSql('ALTER TABLE material_request DROP FOREIGN KEY FK_8A0D543070574616');
  58.         $this->addSql('ALTER TABLE material_request_documents DROP FOREIGN KEY FK_1F02E1BAE24CC4C7');
  59.         $this->addSql('ALTER TABLE material_request_documents DROP FOREIGN KEY FK_1F02E1BA9259118C');
  60.         $this->addSql('ALTER TABLE project_order_task_fulfillment_date_revisions DROP FOREIGN KEY FK_2968491DC55C4AC2');
  61.         $this->addSql('ALTER TABLE project_order_task_fulfillment_messages DROP FOREIGN KEY FK_E763A8DC57125544');
  62.         $this->addSql('DROP TABLE material_request');
  63.         $this->addSql('DROP TABLE material_request_documents');
  64.         $this->addSql('DROP TABLE project_order_task_fulfillment_date_revisions');
  65.         $this->addSql('DROP TABLE project_order_task_fulfillment_messages');
  66.         $this->addSql('DROP TABLE stock_item_groups');
  67.         $this->addSql('ALTER TABLE access_modules CHANGE access_module_role access_module_role VARCHAR(255) DEFAULT NULL');
  68.         $this->addSql('ALTER TABLE branches DROP FOREIGN KEY FK_D760D16F602AD315');
  69.         $this->addSql('DROP INDEX IDX_D760D16F602AD315 ON branches');
  70.         $this->addSql('ALTER TABLE branches DROP responsible_id');
  71.         $this->addSql('ALTER TABLE calculation_permissions CHANGE type type VARCHAR(255) NOT NULL');
  72.         $this->addSql('ALTER TABLE project_order_task_fulfillment DROP status, DROP published_at, DROP accepted_at, DROP declined_at, DROP decline_reason_category, DROP decline_reason, DROP owner_last_read_at, DROP executor_last_read_at, CHANGE reason_id reason_id INT NOT NULL, CHANGE execution_scope execution_scope VARCHAR(255) DEFAULT NULL, CHANGE execution_work_nature execution_work_nature VARCHAR(255) DEFAULT NULL');
  73.         $this->addSql('ALTER TABLE project_order_task_jobs DROP note');
  74.         $this->addSql('ALTER TABLE projects CHANGE type type VARCHAR(255) DEFAULT \'project\'');
  75.         $this->addSql('ALTER TABLE purchase_request_histories CHANGE sender_mode sender_mode VARCHAR(255) DEFAULT NULL');
  76.         $this->addSql('ALTER TABLE purchase_request_status CHANGE status status VARCHAR(255) NOT NULL');
  77.         $this->addSql('ALTER TABLE stock_transactions CHANGE transaction_type transaction_type VARCHAR(255) NOT NULL');
  78.         $this->addSql('DROP INDEX UNIQ_10F47AF1E16C6B94 ON task_fulfillment_reasons');
  79.         $this->addSql('ALTER TABLE todo_notifications CHANGE type type VARCHAR(255) DEFAULT \'status\' NOT NULL, CHANGE status status VARCHAR(255) DEFAULT NULL');
  80.         $this->addSql('ALTER TABLE todos CHANGE priority priority VARCHAR(255) NOT NULL, CHANGE type type VARCHAR(255) NOT NULL, CHANGE status status VARCHAR(255) NOT NULL, CHANGE ai_status ai_status VARCHAR(255) DEFAULT NULL');
  81.         $this->addSql('ALTER TABLE vendor CHANGE vendor_type vendor_type VARCHAR(255) DEFAULT NULL, CHANGE vendor_status vendor_status VARCHAR(255) DEFAULT NULL');
  82.         $this->addSql('ALTER TABLE vendor_contact_persons DROP FOREIGN KEY FK_63C3ABEAA76ED395');
  83.         $this->addSql('DROP INDEX IDX_63C3ABEAA76ED395 ON vendor_contact_persons');
  84.         $this->addSql('ALTER TABLE vendor_contact_persons DROP user_id');
  85.         $this->addSql('DROP INDEX unique_personal_id ON worker');
  86.         $this->addSql('CREATE UNIQUE INDEX unique_personal_id ON worker (personal_id)');
  87.         $this->addSql('ALTER TABLE works_plan_revisions CHANGE status status VARCHAR(255) NOT NULL');
  88.     }
  89. }