<?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 Version20260817172223 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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');
$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');
$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');
$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');
$this->addSql('ALTER TABLE material_request ADD CONSTRAINT FK_8A0D54309F837169 FOREIGN KEY (task_execution_id) REFERENCES project_order_task_fulfillment (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE material_request ADD CONSTRAINT FK_8A0D5430ED442CF4 FOREIGN KEY (requester_id) REFERENCES worker_activities (id)');
$this->addSql('ALTER TABLE material_request ADD CONSTRAINT FK_8A0D543070574616 FOREIGN KEY (reviewer_id) REFERENCES worker_activities (id)');
$this->addSql('ALTER TABLE material_request_documents ADD CONSTRAINT FK_1F02E1BAE24CC4C7 FOREIGN KEY (material_request_id) REFERENCES material_request (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE material_request_documents ADD CONSTRAINT FK_1F02E1BA9259118C FOREIGN KEY (item_group_id) REFERENCES item_groups (id)');
$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');
$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');
$this->addSql('ALTER TABLE access_modules CHANGE access_module_role access_module_role ENUM(\'intern\', \'extern\') DEFAULT NULL');
$this->addSql('ALTER TABLE branches ADD responsible_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE branches ADD CONSTRAINT FK_D760D16F602AD315 FOREIGN KEY (responsible_id) REFERENCES worker_activities (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_D760D16F602AD315 ON branches (responsible_id)');
$this->addSql('ALTER TABLE calculation_permissions CHANGE type type ENUM(\'total\', \'average\', \'profit\', \'margin\', \'detail_report\') NOT NULL');
$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');
$this->addSql('ALTER TABLE project_order_task_jobs ADD note LONGTEXT DEFAULT NULL');
$this->addSql('ALTER TABLE projects CHANGE type type ENUM(\'project\', \'daily_work\') DEFAULT \'project\'');
$this->addSql('ALTER TABLE purchase_request_histories CHANGE sender_mode sender_mode ENUM(\'approver\', \'requester\') DEFAULT NULL');
$this->addSql('ALTER TABLE purchase_request_status CHANGE status status ENUM(\'pending\', \'approved\', \'rejected\', \'delivered\') NOT NULL');
$this->addSql('ALTER TABLE stock_transactions CHANGE transaction_type transaction_type ENUM(\'in\', \'out\', \'move\') NOT NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_10F47AF1E16C6B94 ON task_fulfillment_reasons (alias)');
$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');
$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');
$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');
$this->addSql('ALTER TABLE vendor_contact_persons ADD user_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE vendor_contact_persons ADD CONSTRAINT FK_63C3ABEAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL');
$this->addSql('CREATE INDEX IDX_63C3ABEAA76ED395 ON vendor_contact_persons (user_id)');
$this->addSql('DROP INDEX unique_personal_id ON worker');
$this->addSql('CREATE UNIQUE INDEX unique_personal_id ON worker (personal_id)');
$this->addSql('ALTER TABLE works_plan_revisions CHANGE status status ENUM(\'requested\', \'granted\', \'denied\', \'submitted\', \'approved\', \'rejected\', \'withdrawn\') NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE material_request DROP FOREIGN KEY FK_8A0D54309F837169');
$this->addSql('ALTER TABLE material_request DROP FOREIGN KEY FK_8A0D5430ED442CF4');
$this->addSql('ALTER TABLE material_request DROP FOREIGN KEY FK_8A0D543070574616');
$this->addSql('ALTER TABLE material_request_documents DROP FOREIGN KEY FK_1F02E1BAE24CC4C7');
$this->addSql('ALTER TABLE material_request_documents DROP FOREIGN KEY FK_1F02E1BA9259118C');
$this->addSql('ALTER TABLE project_order_task_fulfillment_date_revisions DROP FOREIGN KEY FK_2968491DC55C4AC2');
$this->addSql('ALTER TABLE project_order_task_fulfillment_messages DROP FOREIGN KEY FK_E763A8DC57125544');
$this->addSql('DROP TABLE material_request');
$this->addSql('DROP TABLE material_request_documents');
$this->addSql('DROP TABLE project_order_task_fulfillment_date_revisions');
$this->addSql('DROP TABLE project_order_task_fulfillment_messages');
$this->addSql('DROP TABLE stock_item_groups');
$this->addSql('ALTER TABLE access_modules CHANGE access_module_role access_module_role VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE branches DROP FOREIGN KEY FK_D760D16F602AD315');
$this->addSql('DROP INDEX IDX_D760D16F602AD315 ON branches');
$this->addSql('ALTER TABLE branches DROP responsible_id');
$this->addSql('ALTER TABLE calculation_permissions CHANGE type type VARCHAR(255) NOT NULL');
$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');
$this->addSql('ALTER TABLE project_order_task_jobs DROP note');
$this->addSql('ALTER TABLE projects CHANGE type type VARCHAR(255) DEFAULT \'project\'');
$this->addSql('ALTER TABLE purchase_request_histories CHANGE sender_mode sender_mode VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE purchase_request_status CHANGE status status VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE stock_transactions CHANGE transaction_type transaction_type VARCHAR(255) NOT NULL');
$this->addSql('DROP INDEX UNIQ_10F47AF1E16C6B94 ON task_fulfillment_reasons');
$this->addSql('ALTER TABLE todo_notifications CHANGE type type VARCHAR(255) DEFAULT \'status\' NOT NULL, CHANGE status status VARCHAR(255) DEFAULT NULL');
$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');
$this->addSql('ALTER TABLE vendor CHANGE vendor_type vendor_type VARCHAR(255) DEFAULT NULL, CHANGE vendor_status vendor_status VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE vendor_contact_persons DROP FOREIGN KEY FK_63C3ABEAA76ED395');
$this->addSql('DROP INDEX IDX_63C3ABEAA76ED395 ON vendor_contact_persons');
$this->addSql('ALTER TABLE vendor_contact_persons DROP user_id');
$this->addSql('DROP INDEX unique_personal_id ON worker');
$this->addSql('CREATE UNIQUE INDEX unique_personal_id ON worker (personal_id)');
$this->addSql('ALTER TABLE works_plan_revisions CHANGE status status VARCHAR(255) NOT NULL');
}
}