migrations/Version20230829112619.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 Version20230829112619 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 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');
  19.         $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');
  20.         $this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794B19EB6921 FOREIGN KEY (client_id) REFERENCES `crm_clients` (id)');
  21.         $this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794B2576E0FD FOREIGN KEY (contract_id) REFERENCES `crm_contracts` (id)');
  22.         $this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794B3E030ACD FOREIGN KEY (application_id) REFERENCES `crm_equipments_applications` (id)');
  23.         $this->addSql('ALTER TABLE `service_travels` ADD CONSTRAINT FK_A87B794BC3C6F69F FOREIGN KEY (car_id) REFERENCES `crm_cars` (id)');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794B19EB6921');
  29.         $this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794B2576E0FD');
  30.         $this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794B3E030ACD');
  31.         $this->addSql('ALTER TABLE `service_travels` DROP FOREIGN KEY FK_A87B794BC3C6F69F');
  32.         $this->addSql('DROP TABLE service_translations');
  33.         $this->addSql('DROP TABLE `service_travels`');
  34.     }
  35. }