<?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 Version20260820132047 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 `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');
$this->addSql('ALTER TABLE `crm_generated_links` ADD CONSTRAINT FK_548D2B93AE80F5DF FOREIGN KEY (department_id) REFERENCES `list_departments` (id)');
$this->addSql('ALTER TABLE `crm_generated_links` ADD CONSTRAINT FK_548D2B936BF700BD FOREIGN KEY (status_id) REFERENCES `list_statuses` (id)');
// Статуси воронки: на проді виконуються лише міграції, тож фікстура сюди їх не привезе
$now = (new \DateTimeImmutable())->format('Y-m-d H:i:s');
$this->addSql("INSERT INTO `list_statuses` (`id`, `type`, `name`, `sorting`, `color`, `created_at`, `updated_at`) VALUES
('generated_link_created', 'generated_link', 'Згенероване посилання', 10, '#ababab', '$now', '$now'),
('generated_link_registered', 'generated_link', 'Клієнт зареєструвався', 20, '#ffd705', '$now', '$now'),
('generated_link_contract', 'generated_link', 'Договір оформлено', 30, '#7ed321', '$now', '$now')");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("DELETE FROM `list_statuses` WHERE `id` IN ('generated_link_created', 'generated_link_registered', 'generated_link_contract')");
$this->addSql('ALTER TABLE `crm_generated_links` DROP FOREIGN KEY FK_548D2B93AE80F5DF');
$this->addSql('ALTER TABLE `crm_generated_links` DROP FOREIGN KEY FK_548D2B936BF700BD');
$this->addSql('DROP TABLE `crm_generated_links`');
}
}