migrations/Version20221203081542.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 Version20221203081542 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 invoices (id INT AUTO_INCREMENT NOT NULL, client_id INT DEFAULT NULL, number INT NOT NULL, date DATETIME NOT NULL, series VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, amount DOUBLE PRECISION NOT NULL, vat DOUBLE PRECISION NOT NULL, due_date DATETIME NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', payment_date DATETIME DEFAULT NULL, information VARCHAR(255) DEFAULT NULL, INDEX IDX_6A2F2F9519EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE invoices_items (id INT AUTO_INCREMENT NOT NULL, invoice_id INT NOT NULL, product_id INT NOT NULL, price DOUBLE PRECISION NOT NULL, quantity INT NOT NULL, INDEX IDX_D80DCB6A2989F1FD (invoice_id), INDEX IDX_D80DCB6A4584665A (product_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE products (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, status INT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('ALTER TABLE invoices ADD CONSTRAINT FK_6A2F2F9519EB6921 FOREIGN KEY (client_id) REFERENCES clients (id)');
  22.         $this->addSql('ALTER TABLE invoices_items ADD CONSTRAINT FK_D80DCB6A2989F1FD FOREIGN KEY (invoice_id) REFERENCES invoices (id)');
  23.         $this->addSql('ALTER TABLE invoices_items ADD CONSTRAINT FK_D80DCB6A4584665A FOREIGN KEY (product_id) REFERENCES products (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 invoices_items DROP FOREIGN KEY FK_D80DCB6A2989F1FD');
  29.         $this->addSql('ALTER TABLE invoices_items DROP FOREIGN KEY FK_D80DCB6A4584665A');
  30.         $this->addSql('DROP TABLE invoices');
  31.         $this->addSql('DROP TABLE invoices_items');
  32.         $this->addSql('DROP TABLE products');
  33.     }
  34. }