migrations/Version20160513162808.php line 1

Open in your IDE?
  1. <?php
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6.  * Auto-generated Migration: Please modify to your needs!
  7.  */
  8. class Version20160513162808 extends AbstractMigration
  9. {
  10.     public function up(Schema $schema): void
  11.     {
  12.         // this up() migration is auto-generated, please modify it to your needs
  13.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql''Migration can only be executed safely on \'mysql\'.');
  14.         $this->addSql('CREATE TABLE truck_maintenance (id INT AUTO_INCREMENT NOT NULL, truck_id INT DEFAULT NULL, detail VARCHAR(255) NOT NULL, date DATETIME NOT NULL, createdAt DATETIME NOT NULL, updatedAt DATETIME NOT NULL, deletedAt DATETIME DEFAULT NULL, amount INT NOT NULL, truckTransaction_id INT DEFAULT NULL, INDEX IDX_A024A92BC6957CCE (truck_id), UNIQUE INDEX UNIQ_A024A92BA854A8F7 (truckTransaction_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  15.         $this->addSql('ALTER TABLE truck_maintenance ADD CONSTRAINT FK_A024A92BC6957CCE FOREIGN KEY (truck_id) REFERENCES truck (id)');
  16.         $this->addSql('ALTER TABLE truck_maintenance ADD CONSTRAINT FK_A024A92BA854A8F7 FOREIGN KEY (truckTransaction_id) REFERENCES truck_transaction (id)');
  17.         $this->addSql('ALTER TABLE truck_transaction ADD truckMaintenace_id INT DEFAULT NULL');
  18.         $this->addSql('ALTER TABLE truck_transaction ADD CONSTRAINT FK_FD975413EB24ABE5 FOREIGN KEY (truckMaintenace_id) REFERENCES truck_maintenance (id) ON DELETE SET NULL');
  19.         $this->addSql('CREATE UNIQUE INDEX UNIQ_FD975413EB24ABE5 ON truck_transaction (truckMaintenace_id)');
  20.     }
  21.     public function down(Schema $schema): void
  22.     {
  23.         // this down() migration is auto-generated, please modify it to your needs
  24.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql''Migration can only be executed safely on \'mysql\'.');
  25.         $this->addSql('ALTER TABLE truck_transaction DROP FOREIGN KEY FK_FD975413EB24ABE5');
  26.         $this->addSql('DROP TABLE truck_maintenance');
  27.         $this->addSql('DROP INDEX UNIQ_FD975413EB24ABE5 ON truck_transaction');
  28.         $this->addSql('ALTER TABLE truck_transaction DROP truckMaintenace_id');
  29.     }
  30. }