migrations/Version20260820132047.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 Version20260820132047 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 `crm_generated_links` (id INT AUTO_INCREMENT NOT NULL, department_id INT NOT NULL, status_id VARCHAR(150) DEFAULT NULL, car_number VARCHAR(50) NOT NULL, comment LONGTEXT DEFAULT NULL, link LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_548D2B93AE80F5DF (department_id), INDEX IDX_548D2B936BF700BD (status_id), UNIQUE INDEX crm_generated_links_car_number_department_idx (car_number, department_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE `crm_generated_links` ADD CONSTRAINT FK_548D2B93AE80F5DF FOREIGN KEY (department_id) REFERENCES `list_departments` (id)');
  20.         $this->addSql('ALTER TABLE `crm_generated_links` ADD CONSTRAINT FK_548D2B936BF700BD FOREIGN KEY (status_id) REFERENCES `list_statuses` (id)');
  21.         // Статуси воронки: на проді виконуються лише міграції, тож фікстура сюди їх не привезе
  22.         $now = (new \DateTimeImmutable())->format('Y-m-d H:i:s');
  23.         $this->addSql("INSERT INTO `list_statuses` (`id`, `type`, `name`, `sorting`, `color`, `created_at`, `updated_at`) VALUES
  24.             ('generated_link_created', 'generated_link', 'Згенероване посилання', 10, '#ababab', '$now', '$now'),
  25.             ('generated_link_registered', 'generated_link', 'Клієнт зареєструвався', 20, '#ffd705', '$now', '$now'),
  26.             ('generated_link_contract', 'generated_link', 'Договір оформлено', 30, '#7ed321', '$now', '$now')");
  27.     }
  28.     public function down(Schema $schema): void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->addSql("DELETE FROM `list_statuses` WHERE `id` IN ('generated_link_created', 'generated_link_registered', 'generated_link_contract')");
  32.         $this->addSql('ALTER TABLE `crm_generated_links` DROP FOREIGN KEY FK_548D2B93AE80F5DF');
  33.         $this->addSql('ALTER TABLE `crm_generated_links` DROP FOREIGN KEY FK_548D2B936BF700BD');
  34.         $this->addSql('DROP TABLE `crm_generated_links`');
  35.     }
  36. }