migrations/Version20210902114822.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 Version20210902114822 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, created_by_id INT DEFAULT NULL, customer_id INT DEFAULT NULL, supplier_id INT DEFAULT NULL, advanced_invoice_id_id INT DEFAULT NULL, date_created DATETIME NOT NULL, type VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, customer_data LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', invoice_number VARCHAR(255) DEFAULT NULL, invoice_number_iterator INT NOT NULL, total_sum NUMERIC(10, 2) NOT NULL, paid_sum NUMERIC(10, 2) NOT NULL, date_due DATETIME NOT NULL, date_fully_paid DATETIME DEFAULT NULL, comment LONGTEXT DEFAULT NULL, currency VARCHAR(255) NOT NULL, invoice_file LONGTEXT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', UNIQUE INDEX UNIQ_90651744D17F50A6 (uuid), INDEX IDX_90651744B03A8386 (created_by_id), INDEX IDX_906517449395C3F3 (customer_id), INDEX IDX_906517442ADD6D8C (supplier_id), INDEX IDX_9065174412398576 (advanced_invoice_id_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE invoice_row (id INT AUTO_INCREMENT NOT NULL, invoice_id INT DEFAULT NULL, invoice_mapping_id INT DEFAULT NULL, description LONGTEXT NOT NULL, price NUMERIC(12, 4) NOT NULL, quantity NUMERIC(12, 4) NOT NULL, discount NUMERIC(12, 4) NOT NULL, units VARCHAR(255) DEFAULT NULL, tax NUMERIC(12, 4) NOT NULL, tax_type VARCHAR(255) NOT NULL, cost_centre VARCHAR(255) NOT NULL, code VARCHAR(255) DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', UNIQUE INDEX UNIQ_2CC19918D17F50A6 (uuid), INDEX IDX_2CC199182989F1FD (invoice_id), INDEX IDX_2CC199183670752 (invoice_mapping_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE payment (id INT AUTO_INCREMENT NOT NULL, invoice_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, due_amount NUMERIC(12, 4) NOT NULL, due_date DATETIME NOT NULL, paid_amount NUMERIC(12, 4) NOT NULL, date_fully_paid DATETIME DEFAULT NULL, payment_method VARCHAR(255) DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', UNIQUE INDEX UNIQ_6D28840DD17F50A6 (uuid), INDEX IDX_6D28840D2989F1FD (invoice_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE supplier (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, registration_nr VARCHAR(255) DEFAULT NULL, vatnr VARCHAR(255) DEFAULT NULL, is_active TINYINT(1) NOT NULL, banking_details LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', address_details LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', country VARCHAR(255) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, person_name VARCHAR(255) DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', UNIQUE INDEX UNIQ_9B2A6C7ED17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_90651744B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
  23.         $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_906517449395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
  24.         $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_906517442ADD6D8C FOREIGN KEY (supplier_id) REFERENCES supplier (id)');
  25.         $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_9065174412398576 FOREIGN KEY (advanced_invoice_id_id) REFERENCES invoice (id)');
  26.         $this->addSql('ALTER TABLE invoice_row ADD CONSTRAINT FK_2CC199182989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
  27.         $this->addSql('ALTER TABLE invoice_row ADD CONSTRAINT FK_2CC199183670752 FOREIGN KEY (invoice_mapping_id) REFERENCES invoice (id)');
  28.         $this->addSql('ALTER TABLE payment ADD CONSTRAINT FK_6D28840D2989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->addSql('ALTER TABLE invoice DROP FOREIGN KEY FK_9065174412398576');
  34.         $this->addSql('ALTER TABLE invoice_row DROP FOREIGN KEY FK_2CC199182989F1FD');
  35.         $this->addSql('ALTER TABLE invoice_row DROP FOREIGN KEY FK_2CC199183670752');
  36.         $this->addSql('ALTER TABLE payment DROP FOREIGN KEY FK_6D28840D2989F1FD');
  37.         $this->addSql('ALTER TABLE invoice DROP FOREIGN KEY FK_906517442ADD6D8C');
  38.         $this->addSql('DROP TABLE invoice');
  39.         $this->addSql('DROP TABLE invoice_row');
  40.         $this->addSql('DROP TABLE payment');
  41.         $this->addSql('DROP TABLE supplier');
  42.     }
  43. }