<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20150807100740 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', "Migration can only be executed safely on 'mysql'.");
$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');
$this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_90651744BE04EA9 FOREIGN KEY (job_id) REFERENCES job (id)');
$this->addSql('ALTER TABLE job ADD invoice_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE job ADD CONSTRAINT FK_FBD8E0F82989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_FBD8E0F82989F1FD ON job (invoice_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', "Migration can only be executed safely on 'mysql'.");
$this->addSql('ALTER TABLE job DROP FOREIGN KEY FK_FBD8E0F82989F1FD');
$this->addSql('DROP TABLE invoice');
$this->addSql('DROP INDEX UNIQ_FBD8E0F82989F1FD ON job');
$this->addSql('ALTER TABLE job DROP invoice_id');
}
}