migrations/Version20251223070255.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 Version20251223070255 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_item (id INT AUTO_INCREMENT NOT NULL, invoice_id INT DEFAULT NULL, product_id INT DEFAULT NULL, selected_unit_id INT DEFAULT NULL, product_name VARCHAR(255) NOT NULL, measurement VARCHAR(255) NOT NULL, quantity NUMERIC(10, 4) NOT NULL, unit_price_fob NUMERIC(10, 3) NOT NULL, unit_price_navlun NUMERIC(10, 3) NOT NULL, total_unit_price NUMERIC(10, 3) NOT NULL, total_purchase_price NUMERIC(10, 3) NOT NULL, total_unit_purchase_price NUMERIC(10, 3) NOT NULL, tax NUMERIC(10, 0) NOT NULL, discount NUMERIC(10, 0) NOT NULL, un_allocated_quantity NUMERIC(10, 4) NOT NULL, base_unit_quantity NUMERIC(10, 4) NOT NULL, created_at DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', updated_at DATE DEFAULT NULL COMMENT \'(DC2Type:date_immutable)\', created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, u_date INT DEFAULT NULL, INDEX IDX_1DDE477B2989F1FD (invoice_id), INDEX IDX_1DDE477B4584665A (product_id), INDEX IDX_1DDE477B10F90E93 (selected_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('ALTER TABLE invoice_item ADD CONSTRAINT FK_1DDE477B2989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
  20.         $this->addSql('ALTER TABLE invoice_item ADD CONSTRAINT FK_1DDE477B4584665A FOREIGN KEY (product_id) REFERENCES product (id)');
  21.         $this->addSql('ALTER TABLE invoice_item ADD CONSTRAINT FK_1DDE477B10F90E93 FOREIGN KEY (selected_unit_id) REFERENCES measurement_units (id) ON DELETE SET NULL');
  22.     }
  23.     public function down(Schema $schema): void
  24.     {
  25.         // this down() migration is auto-generated, please modify it to your needs
  26.         $this->addSql('ALTER TABLE invoice_item DROP FOREIGN KEY FK_1DDE477B2989F1FD');
  27.         $this->addSql('ALTER TABLE invoice_item DROP FOREIGN KEY FK_1DDE477B4584665A');
  28.         $this->addSql('ALTER TABLE invoice_item DROP FOREIGN KEY FK_1DDE477B10F90E93');
  29.         $this->addSql('DROP TABLE invoice_item');
  30.     }
  31. }