<?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 Version20230829112619 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 service_translations (id INT AUTO_INCREMENT NOT NULL, locale VARCHAR(8) NOT NULL, object_class VARCHAR(191) NOT NULL, field VARCHAR(32) NOT NULL, foreign_key VARCHAR(64) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX service_translations_idx (locale, object_class, field, foreign_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE `service_travels` (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, contract_id INT NOT NULL, application_id INT NOT NULL, car_id INT NOT NULL, external_code VARCHAR(255) DEFAULT NULL, ext_start_timestamp VARCHAR(20) NOT NULL, ext_end_timestamp VARCHAR(20) NOT NULL, rating DOUBLE PRECISION DEFAULT \'0\' NOT NULL, start_date DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', start_address VARCHAR(255) DEFAULT NULL, start_gps LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', end_date DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', end_address VARCHAR(255) DEFAULT NULL, end_gps LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', duration VARCHAR(255) DEFAULT NULL COMMENT \'(DC2Type:dateinterval)\', mileage DOUBLE PRECISION DEFAULT \'0\' NOT NULL, correct_mileage DOUBLE PRECISION DEFAULT \'0\' NOT NULL, city_mileage DOUBLE PRECISION DEFAULT \'0\' NOT NULL, final_mileage DOUBLE PRECISION DEFAULT \'0\' NOT NULL, avg_speed INT DEFAULT 0 NOT NULL, max_speed INT DEFAULT 0 NOT NULL, max_speed_gps LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_A87B794BE20A50B4 (external_code), INDEX IDX_A87B794B19EB6921 (client_id), INDEX IDX_A87B794B2576E0FD (contract_id), INDEX IDX_A87B794B3E030ACD (application_id), INDEX IDX_A87B794BC3C6F69F (car_id), INDEX service_travels_custom_idx (ext_start_timestamp, ext_end_timestamp), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794B19EB6921 FOREIGN KEY (client_id) REFERENCES `crm_clients` (id)');
$this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794B2576E0FD FOREIGN KEY (contract_id) REFERENCES `crm_contracts` (id)');
$this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794B3E030ACD FOREIGN KEY (application_id) REFERENCES `crm_equipments_applications` (id)');
$this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794BC3C6F69F FOREIGN KEY (car_id) REFERENCES `crm_cars` (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794B19EB6921');
$this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794B2576E0FD');
$this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794B3E030ACD');
$this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794BC3C6F69F');
$this->addSql('DROP TABLE service_translations');
$this->addSql('DROP TABLE `service_travels`');
}
}