<?php
declare(strict_types=1);
namespace TicketsBundleMigrations;
use Doctrine\DBAL\Schema\Schema;
use App\Services\ObjectSerialize;
use Symfony\Component\Uid\UuidV6;
use Doctrine\Migrations\AbstractMigration;
final class Version20230816145037 extends AbstractMigration
{
private ObjectSerialize $objectSerialize;
public function setObjectSerialize(ObjectSerialize $objectSerialize)
{
$this->objectSerialize = $objectSerialize;
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE tickets_bundle__predefined_message (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', ticket_state_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(64) NOT NULL, content LONGTEXT DEFAULT NULL, cc LONGTEXT DEFAULT NULL, bcc LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, is_active TINYINT(1) DEFAULT 1 NOT NULL, INDEX IDX_A8BDD2EC80B1C040 (ticket_state_id), INDEX IDX_A8BDD2ECB03A8386 (created_by_id), INDEX IDX_A8BDD2EC896DBBDE (updated_by_id), INDEX IDX_A8BDD2ECC76F1F52 (deleted_by_id), INDEX name (name), INDEX is_active (is_active), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__predefined_message_status_change (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', content LONGTEXT NOT NULL, status INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, is_active TINYINT(1) DEFAULT 1 NOT NULL, INDEX IDX_1F55438FB03A8386 (created_by_id), INDEX IDX_1F55438F896DBBDE (updated_by_id), INDEX is_active (is_active), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__predefined_message_status_change_translations (id INT AUTO_INCREMENT NOT NULL, object_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_8347860F232D562B (object_id), FULLTEXT INDEX content (content), UNIQUE INDEX lookup_unique_idx (locale, object_id, field), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__predefined_message_translations (id INT AUTO_INCREMENT NOT NULL, object_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_36D82C4E232D562B (object_id), FULLTEXT INDEX content (content), UNIQUE INDEX lookup_unique_idx (locale, object_id, field), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__relaunch (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', original_ticket_state_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', final_ticket_state_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', days INT NOT NULL, content LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, is_active TINYINT(1) DEFAULT 1 NOT NULL, INDEX IDX_99EB8B45429D24CA (original_ticket_state_id), INDEX IDX_99EB8B453EC1430 (final_ticket_state_id), INDEX IDX_99EB8B45B03A8386 (created_by_id), INDEX IDX_99EB8B45896DBBDE (updated_by_id), INDEX IDX_99EB8B45C76F1F52 (deleted_by_id), INDEX days (days), INDEX is_active (is_active), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__ticket (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', ticket_state_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', merged_ticket_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', thread_id VARCHAR(256) DEFAULT NULL, created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', number INT NOT NULL, is_spam TINYINT(1) DEFAULT 0 NOT NULL, `level` INT DEFAULT 0 NOT NULL, `from` LONGTEXT NOT NULL, cc LONGTEXT DEFAULT NULL, bcc LONGTEXT DEFAULT NULL, subject VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_F69B6D7280B1C040 (ticket_state_id), INDEX IDX_F69B6D725B62A416 (merged_ticket_id), INDEX IDX_F69B6D72B03A8386 (created_by_id), INDEX IDX_F69B6D72896DBBDE (updated_by_id), INDEX IDX_F69B6D72C76F1F52 (deleted_by_id), INDEX level (level), INDEX number (number), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__ticket_message (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', ticket_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', api_id VARCHAR(256) DEFAULT NULL, `from` LONGTEXT DEFAULT NULL, cc LONGTEXT DEFAULT NULL, bcc LONGTEXT DEFAULT NULL, subject VARCHAR(255) DEFAULT NULL, reference LONGTEXT DEFAULT NULL, content LONGTEXT DEFAULT NULL, is_internal TINYINT(1) DEFAULT 0 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_763429B7700047D2 (ticket_id), INDEX IDX_763429B7B03A8386 (created_by_id), INDEX IDX_763429B7896DBBDE (updated_by_id), INDEX IDX_763429B7C76F1F52 (deleted_by_id), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__ticket_message_attachment (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', ticket_message_id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', file_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', content LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_C60E6310C5E9817D (ticket_message_id), INDEX IDX_C60E631093CB796C (file_id), INDEX IDX_C60E6310B03A8386 (created_by_id), INDEX IDX_C60E6310896DBBDE (updated_by_id), INDEX IDX_C60E6310C76F1F52 (deleted_by_id), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__ticket_state (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(64) NOT NULL, color VARCHAR(7) NOT NULL, position INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, is_active TINYINT(1) DEFAULT 1 NOT NULL, is_default TINYINT(1) NOT NULL, INDEX IDX_D5EB4896B03A8386 (created_by_id), INDEX IDX_D5EB4896896DBBDE (updated_by_id), INDEX IDX_D5EB4896C76F1F52 (deleted_by_id), INDEX name (name), INDEX color (color), INDEX position (position), INDEX is_active (is_active), INDEX is_default (is_default), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tickets_bundle__ticket_state_translations (id INT AUTO_INCREMENT NOT NULL, object_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', locale VARCHAR(8) NOT NULL, field VARCHAR(32) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX IDX_A32745DE232D562B (object_id), FULLTEXT INDEX content (content), UNIQUE INDEX lookup_unique_idx (locale, object_id, field), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message ADD CONSTRAINT FK_A8BDD2EC80B1C040 FOREIGN KEY (ticket_state_id) REFERENCES tickets_bundle__ticket_state (id)');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message ADD CONSTRAINT FK_A8BDD2ECB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message ADD CONSTRAINT FK_A8BDD2EC896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message ADD CONSTRAINT FK_A8BDD2ECC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_status_change ADD CONSTRAINT FK_1F55438FB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_status_change ADD CONSTRAINT FK_1F55438F896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_status_change_translations ADD CONSTRAINT FK_8347860F232D562B FOREIGN KEY (object_id) REFERENCES tickets_bundle__predefined_message_status_change (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_translations ADD CONSTRAINT FK_36D82C4E232D562B FOREIGN KEY (object_id) REFERENCES tickets_bundle__predefined_message (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE tickets_bundle__relaunch ADD CONSTRAINT FK_99EB8B45429D24CA FOREIGN KEY (original_ticket_state_id) REFERENCES tickets_bundle__ticket_state (id)');
$this->addSql('ALTER TABLE tickets_bundle__relaunch ADD CONSTRAINT FK_99EB8B453EC1430 FOREIGN KEY (final_ticket_state_id) REFERENCES tickets_bundle__ticket_state (id)');
$this->addSql('ALTER TABLE tickets_bundle__relaunch ADD CONSTRAINT FK_99EB8B45B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__relaunch ADD CONSTRAINT FK_99EB8B45896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__relaunch ADD CONSTRAINT FK_99EB8B45C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket ADD CONSTRAINT FK_F69B6D7280B1C040 FOREIGN KEY (ticket_state_id) REFERENCES tickets_bundle__ticket_state (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket ADD CONSTRAINT FK_F69B6D725B62A416 FOREIGN KEY (merged_ticket_id) REFERENCES tickets_bundle__ticket (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket ADD CONSTRAINT FK_F69B6D72B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket ADD CONSTRAINT FK_F69B6D72896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket ADD CONSTRAINT FK_F69B6D72C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message ADD CONSTRAINT FK_763429B7700047D2 FOREIGN KEY (ticket_id) REFERENCES tickets_bundle__ticket (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message ADD CONSTRAINT FK_763429B7B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message ADD CONSTRAINT FK_763429B7896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message ADD CONSTRAINT FK_763429B7C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment ADD CONSTRAINT FK_C60E6310C5E9817D FOREIGN KEY (ticket_message_id) REFERENCES tickets_bundle__ticket_message (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment ADD CONSTRAINT FK_C60E631093CB796C FOREIGN KEY (file_id) REFERENCES file_manager (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment ADD CONSTRAINT FK_C60E6310B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment ADD CONSTRAINT FK_C60E6310896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment ADD CONSTRAINT FK_C60E6310C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state ADD CONSTRAINT FK_D5EB4896B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state ADD CONSTRAINT FK_D5EB4896896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state ADD CONSTRAINT FK_D5EB4896C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state_translations ADD CONSTRAINT FK_A32745DE232D562B FOREIGN KEY (object_id) REFERENCES tickets_bundle__ticket_state (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE tickets_bundle__predefined_message DROP FOREIGN KEY FK_A8BDD2EC80B1C040');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message DROP FOREIGN KEY FK_A8BDD2ECB03A8386');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message DROP FOREIGN KEY FK_A8BDD2EC896DBBDE');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message DROP FOREIGN KEY FK_A8BDD2ECC76F1F52');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_status_change DROP FOREIGN KEY FK_1F55438FB03A8386');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_status_change DROP FOREIGN KEY FK_1F55438F896DBBDE');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_status_change_translations DROP FOREIGN KEY FK_8347860F232D562B');
$this->addSql('ALTER TABLE tickets_bundle__predefined_message_translations DROP FOREIGN KEY FK_36D82C4E232D562B');
$this->addSql('ALTER TABLE tickets_bundle__relaunch DROP FOREIGN KEY FK_99EB8B45429D24CA');
$this->addSql('ALTER TABLE tickets_bundle__relaunch DROP FOREIGN KEY FK_99EB8B453EC1430');
$this->addSql('ALTER TABLE tickets_bundle__relaunch DROP FOREIGN KEY FK_99EB8B45B03A8386');
$this->addSql('ALTER TABLE tickets_bundle__relaunch DROP FOREIGN KEY FK_99EB8B45896DBBDE');
$this->addSql('ALTER TABLE tickets_bundle__relaunch DROP FOREIGN KEY FK_99EB8B45C76F1F52');
$this->addSql('ALTER TABLE tickets_bundle__ticket DROP FOREIGN KEY FK_F69B6D7280B1C040');
$this->addSql('ALTER TABLE tickets_bundle__ticket DROP FOREIGN KEY FK_F69B6D725B62A416');
$this->addSql('ALTER TABLE tickets_bundle__ticket DROP FOREIGN KEY FK_F69B6D72B03A8386');
$this->addSql('ALTER TABLE tickets_bundle__ticket DROP FOREIGN KEY FK_F69B6D72896DBBDE');
$this->addSql('ALTER TABLE tickets_bundle__ticket DROP FOREIGN KEY FK_F69B6D72C76F1F52');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message DROP FOREIGN KEY FK_763429B7700047D2');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message DROP FOREIGN KEY FK_763429B7B03A8386');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message DROP FOREIGN KEY FK_763429B7896DBBDE');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message DROP FOREIGN KEY FK_763429B7C76F1F52');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment DROP FOREIGN KEY FK_C60E6310C5E9817D');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment DROP FOREIGN KEY FK_C60E631093CB796C');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment DROP FOREIGN KEY FK_C60E6310B03A8386');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment DROP FOREIGN KEY FK_C60E6310896DBBDE');
$this->addSql('ALTER TABLE tickets_bundle__ticket_message_attachment DROP FOREIGN KEY FK_C60E6310C76F1F52');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state DROP FOREIGN KEY FK_D5EB4896B03A8386');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state DROP FOREIGN KEY FK_D5EB4896896DBBDE');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state DROP FOREIGN KEY FK_D5EB4896C76F1F52');
$this->addSql('ALTER TABLE tickets_bundle__ticket_state_translations DROP FOREIGN KEY FK_A32745DE232D562B');
$this->addSql('DROP TABLE tickets_bundle__predefined_message');
$this->addSql('DROP TABLE tickets_bundle__predefined_message_status_change');
$this->addSql('DROP TABLE tickets_bundle__predefined_message_status_change_translations');
$this->addSql('DROP TABLE tickets_bundle__predefined_message_translations');
$this->addSql('DROP TABLE tickets_bundle__relaunch');
$this->addSql('DROP TABLE tickets_bundle__ticket');
$this->addSql('DROP TABLE tickets_bundle__ticket_message');
$this->addSql('DROP TABLE tickets_bundle__ticket_message_attachment');
$this->addSql('DROP TABLE tickets_bundle__ticket_state');
$this->addSql('DROP TABLE tickets_bundle__ticket_state_translations');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$now = (new \DateTime())->format('Y-m-d H:i:s');
$languages = $this->connection->executeQuery('SELECT * FROM language WHERE deleted_at IS NULL')
->fetchAllAssociative();
$rootLocale = 'en';
$defaultLocale = $this->connection
->executeQuery('SELECT locale FROM language WHERE deleted_at IS NULL AND is_default = 1')
->fetchOne() ?: 'en';
$ticketStates = [
[
'names' => ['fr' => 'Ouvert', 'en' => 'Open'],
'color' => '#e55d43',
'is_default' => true,
'position' => 1
],
[
'names' => ['fr' => 'Attente', 'en' => 'Waiting'],
'color' => '#3fa1ed',
'is_default' => false,
'position' => 2
],
[
'names' => ['fr' => 'Relancé', 'en' => 'Relaunched'],
'color' => '#df821c',
'is_default' => false,
'position' => 3
],
[
'names' => ['fr' => 'Résolu', 'en' => 'Solved'],
'color' => '#a39b8f',
'is_default' => false,
'position' => 4
],
[
'names' => ['fr' => 'Clos', 'en' => 'Closed'],
'color' => '#000000',
'is_default' => false,
'closed' => true,
'position' => 5
]
];
foreach ($ticketStates as $ticketState) {
$ticketStateId = new UuidV6();
$ticketStateIdStr = $ticketStateId->toRfc4122();
$ticketStateId = $ticketStateId->toBinary();
$this->connection->insert('tickets_bundle__ticket_state', [
'id' => $ticketStateId,
'name' => !empty($ticketState['names'][$defaultLocale]) ?
$ticketState['names'][$defaultLocale] : $ticketState['names'][$rootLocale],
'color' => $ticketState['color'],
'position' => $ticketState['position'],
'is_active' => 1,
'is_default' => (int) $ticketState['is_default'],
'created_at' => $now,
'updated_at' => $now
]);
if (isset($ticketState['closed'])) {
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => 'tickets_bundle__closed_ticket_state',
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => $ticketStateIdStr]),
'created_at' => $now,
'updated_at' => $now
]);
}
foreach ($languages as $language) {
$localeTo = $rootLocale;
if (!empty($ticketState['names'][$language['locale']])) {
$localeTo = $language['locale'];
} elseif (!empty($ticketState['names'][$defaultLocale])) {
$localeTo = $defaultLocale;
}
$this->connection->insert('tickets_bundle__ticket_state_translations', [
'object_id' => $ticketStateId,
'locale' => $language['locale'],
'field' => 'name',
'content' => $ticketState['names'][$localeTo]
]);
}
}
$messages = [
[
'contents' => [
'fr' => '<p>Bonjour,</p><p>Votre demande a été transférée au niveau N0.</p><p><strong>Veuillez noter que cette réponse est générée automatiquement.</strong></p>',
'en' => '<p>Hello,</p><p>Your request has been transferred to level N0.</p><p><strong>Please note that this response is generated automatically.</strong></p>'
],
'status' => 0
],
[
'contents' => [
'fr' => '<p>Bonjour,</p><p>Votre demande a été transférée au niveau N1.</p>',
'en' => '<p>Hello,</p><p>Your request has been transferred to level N1.</p>'
],
'status' => 1
],
[
'contents' => [
'fr' => '<p>Bonjour,</p><p>Votre demande a été transférée au niveau N2.</p>',
'en' => '<p>Hello,</p><p>Your request has been transferred to level N2.</p>'
],
'status' => 2
]
];
foreach ($messages as $message) {
$messageId = (new UuidV6())->toBinary();
$this->connection->insert('tickets_bundle__predefined_message_status_change', [
'id' => $messageId,
'content' => !empty($message['contents'][$defaultLocale]) ?
$message['contents'][$defaultLocale] : $message['contents'][$rootLocale],
'status' => $message['status'],
'created_at' => $now,
'updated_at' => $now
]);
foreach ($languages as $language) {
$localeTo = $rootLocale;
if (!empty($message['contents'][$language['locale']])) {
$localeTo = $language['locale'];
} elseif (!empty($message['contents'][$defaultLocale])) {
$localeTo = $defaultLocale;
}
$this->connection->insert('tickets_bundle__predefined_message_status_change_translations', [
'object_id' => $messageId,
'locale' => $language['locale'],
'field' => 'content',
'content' => $message['contents'][$localeTo]
]);
}
}
$this->connection->insert('cron_job', [
'name' => 'tickets-relaunch',
'command' => 'bluue-bundle:tickets:relaunch',
'schedule' => '0 6 * * *',
'description' => '',
'enabled' => 0
]);
$this->connection->insert('cron_job', [
'name' => 'mail-retrieval',
'command' => 'bluue-bundle:tickets:gmail-list',
'schedule' => '*/1 * * * *',
'description' => '',
'enabled' => 0
]);
$content = '<p>Bonjour,</p><p> </p><p>Il n\'y a pas de contrats permettant d\'être géré par ';
$content .= 'le support et donc ce ticket est renvoyé au commerce.</p>';
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => 'tickets_bundle__trade_referral_mail_content',
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => $content]),
'created_at' => $now,
'updated_at' => $now
]);
$fixtureFile = dirname(__FILE__) . '/../src/Resources/views/Mail/Fixtures/layout.html.twig';
$mailLayout = file_get_contents($fixtureFile);
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => 'tickets_bundle__mail_layout',
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => $mailLayout]),
'created_at' => $now,
'updated_at' => $now
]);
}
}