migrations/Version20221108040939.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 Version20221108040939 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 invoice (id INT AUTO_INCREMENT NOT NULL, partner_id INT DEFAULT NULL, ym VARCHAR(6) NOT NULL, invoice_date DATETIME DEFAULT NULL, total INT DEFAULT NULL, pdf_filename VARCHAR(100) NOT NULL, print_date DATETIME DEFAULT NULL, create_date DATETIME NOT NULL, delete_date DATETIME DEFAULT NULL, INDEX IDX_906517449393F8FE (partner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_906517449393F8FE FOREIGN KEY (partner_id) REFERENCES partner (id)');
  20.         $this->addSql('ALTER TABLE sales ADD invoice_id INT DEFAULT NULL');
  21.         $this->addSql('ALTER TABLE sales ADD CONSTRAINT FK_6B8170442989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
  22.         $this->addSql('CREATE INDEX IDX_6B8170442989F1FD ON sales (invoice_id)');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // this down() migration is auto-generated, please modify it to your needs
  27.         $this->addSql('ALTER TABLE sales DROP FOREIGN KEY FK_6B8170442989F1FD');
  28.         $this->addSql('ALTER TABLE invoice DROP FOREIGN KEY FK_906517449393F8FE');
  29.         $this->addSql('DROP TABLE invoice');
  30.         $this->addSql('DROP INDEX IDX_6B8170442989F1FD ON sales');
  31.         $this->addSql('ALTER TABLE sales DROP invoice_id');
  32.     }
  33. }