migrations/Version20150807100740.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 Version20150807100740 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 invoice (id INT AUTO_INCREMENT NOT NULL, job_id INT DEFAULT NULL, status VARCHAR(255) DEFAULT NULL, is_sent TINYINT(1) NOT NULL, is_paid TINYINT(1) NOT NULL, is_queried TINYINT(1) NOT NULL, completion_stage INT NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, deletedAt DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_90651744BE04EA9 (job_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  15.         $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_90651744BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id)');
  16.         $this->addSql('ALTER TABLE job ADD invoice_id INT DEFAULT NULL');
  17.         $this->addSql('ALTER TABLE job ADD CONSTRAINT FK_FBD8E0F82989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
  18.         $this->addSql('CREATE UNIQUE INDEX UNIQ_FBD8E0F82989F1FD ON job (invoice_id)');
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         // this down() migration is auto-generated, please modify it to your needs
  23.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql'"Migration can only be executed safely on 'mysql'.");
  24.         $this->addSql('ALTER TABLE job DROP FOREIGN KEY FK_FBD8E0F82989F1FD');
  25.         $this->addSql('DROP TABLE invoice');
  26.         $this->addSql('DROP INDEX UNIQ_FBD8E0F82989F1FD ON job');
  27.         $this->addSql('ALTER TABLE job DROP invoice_id');
  28.     }
  29. }