migrations/2023/02/Version20230219211826.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20230219211826 extends AbstractMigration
  7. {
  8.     public function up(Schema $schema): void
  9.     {
  10.         $this->addSql('ALTER TABLE profit_calculation_row DROP FOREIGN KEY FK_E32377A3ECFF285C');
  11.         $this->addSql('DROP TABLE profit_calculation');
  12.         $this->addSql('DROP TABLE profit_calculation_row');
  13.     }
  14.     public function down(Schema $schema): void
  15.     {
  16.         $this->addSql('CREATE TABLE profit_calculation (id BINARY(16) NOT NULL COMMENT \'(DC2Type:profit_calculation_id)\', contact_id BINARY(16) NOT NULL COMMENT \'(DC2Type:contact_id)\', associated_contact_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:contact_id)\', title VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, year VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, active INT DEFAULT 1 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_429D0587E7A1254A (contact_id), INDEX IDX_429D0587C16040B (associated_contact_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
  17.         $this->addSql('CREATE TABLE profit_calculation_row (id BINARY(16) NOT NULL COMMENT \'(DC2Type:profit_calculation_item_id)\', table_id BINARY(16) NOT NULL COMMENT \'(DC2Type:profit_calculation_id)\', name VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, amount NUMERIC(10, 2) UNSIGNED DEFAULT \'0.00\' NOT NULL, row_type INT NOT NULL, date_time DATETIME NOT NULL, INDEX IDX_E32377A3ECFF285C (table_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
  18.         $this->addSql('ALTER TABLE profit_calculation ADD CONSTRAINT FK_429D0587C16040B FOREIGN KEY (associated_contact_id) REFERENCES contact (id)');
  19.         $this->addSql('ALTER TABLE profit_calculation ADD CONSTRAINT FK_429D0587E7A1254A FOREIGN KEY (contact_id) REFERENCES contact (id)');
  20.         $this->addSql('ALTER TABLE profit_calculation_row ADD CONSTRAINT FK_E32377A3ECFF285C FOREIGN KEY (table_id) REFERENCES profit_calculation (id)');
  21.     }
  22. }