migrations/Version20200609102733.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Application\Migrations;
  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 Version20200609102733 extends AbstractMigration
  10. {
  11.     public function up(Schema $schema): void
  12.     {
  13.         $this->addSql('RENAME TABLE non_member_billing_company  TO legal_entity_billing_company');
  14.         $this->addSql('RENAME TABLE non_member_billing_contact_person TO legal_entity_billing_contact_person');
  15.         $this->addSql('RENAME TABLE non_member_contract TO legal_entity_contract');
  16.         $this->addSql('RENAME TABLE non_member_license_agreement TO legal_entity_license_agreement');
  17.         $this->addSql('RENAME TABLE non_member_order_invoice_item TO legal_entity_order_invoice_item');
  18.         $this->addSql('RENAME TABLE non_member_order_invoice_manual TO legal_entity_order_invoice_manual');
  19.         $this->addSql('RENAME TABLE non_member_order_invoice_manual_item TO legal_entity_order_invoice_manual_item');
  20.         $this->addSql('RENAME TABLE non_member_order_invoice_reminder TO legal_entity_order_invoice_reminder');
  21.         $this->addSql('RENAME TABLE non_member_order_invoice TO legal_entity_order_invoice');
  22.         $this->addSql('RENAME TABLE non_member_order TO legal_entity_order');
  23.         $this->addSql('RENAME TABLE non_member_order_line_dossiers TO legal_entity_order_line_dossiers');
  24.         $this->addSql('RENAME TABLE non_member_order_line_dossiers_pending TO legal_entity_order_line_dossiers_pending');
  25.         $this->addSql('RENAME TABLE non_member_order_line TO legal_entity_order_line');
  26.         $this->addSql('RENAME TABLE non_member_order_line_status TO legal_entity_order_line_status');
  27.         $this->addSql('RENAME TABLE non_member_order_reinvoicing_line TO legal_entity_order_reinvoicing_line');
  28.         $this->addSql('RENAME TABLE non_member_active_definition TO legal_entity_active_definition');
  29.         $this->addSql('RENAME TABLE non_member_cart_line TO legal_entity_cart_line');
  30.         $this->addSql('RENAME TABLE member_company_remark TO legal_entity_member_company_remark');
  31.         $this->addSql('RENAME TABLE member_company TO legal_entity_member_company');
  32.         $this->addSql('ALTER TABLE legal_entity ADD COLUMN member TINYINT(1)');
  33.         $this->addSql('ALTER TABLE `legal_entity` CHANGE `company_id` `member_company_id` INT(11) NULL DEFAULT NULL;');
  34.         $this->addSql('UPDATE legal_entity SET member = 1 WHERE _discr = :member', ['member' => 'member']);
  35.         $this->addSql('UPDATE legal_entity SET member = 0 WHERE _discr != :member', ['member' => 'member']);
  36.         $this->addSql('UPDATE legal_entity SET active_definition_id = null');
  37.         $this->addSql('ALTER TABLE `legal_entity` DROP COLUMN `_discr`');
  38.         $this->addSql('ALTER TABLE `legal_entity_order` CHANGE `number` `number` INT(11) NULL;');
  39.     }
  40.     public function down(Schema $schema): void
  41.     {
  42.         $this->addSql('RENAME TABLE legal_entity_billing_company  TO non_member_billing_company');
  43.         $this->addSql('RENAME TABLE legal_entity_billing_contact_person TO non_member_billing_contact_person');
  44.         $this->addSql('RENAME TABLE legal_entity_contract TO non_member_contract');
  45.         $this->addSql('RENAME TABLE legal_entity_license_agreement TO non_member_license_agreement');
  46.         $this->addSql('RENAME TABLE legal_entity_order_invoice_item TO non_member_order_invoice_item');
  47.         $this->addSql('RENAME TABLE legal_entity_order_invoice_manual TO non_member_order_invoice_manual');
  48.         $this->addSql('RENAME TABLE legal_entity_order_invoice_manual_item TO non_member_order_invoice_manual_item');
  49.         $this->addSql('RENAME TABLE legal_entity_order_invoice_reminder TO non_member_order_invoice_reminder');
  50.         $this->addSql('RENAME TABLE legal_entity_order_invoice TO non_member_order_invoice');
  51.         $this->addSql('RENAME TABLE legal_entity_order TO non_member_order');
  52.         $this->addSql('RENAME TABLE legal_entity_order_line_dossiers TO non_member_order_line_dossiers');
  53.         $this->addSql('RENAME TABLE legal_entity_order_line_dossiers_pending TO non_member_order_line_dossiers_pending');
  54.         $this->addSql('RENAME TABLE legal_entity_order_line TO non_member_order_line');
  55.         $this->addSql('RENAME TABLE legal_entity_order_line_status TO non_member_order_line_status');
  56.         $this->addSql('RENAME TABLE legal_entity_order_reinvoicing_line TO non_member_order_reinvoicing_line');
  57.         $this->addSql('RENAME TABLE legal_entity_active_definition TO non_member_active_definition');
  58.         $this->addSql('RENAME TABLE legal_entity_cart_line TO non_member_cart_line');
  59.         $this->addSql('RENAME TABLE legal_entity_member_company_remark TO member_company_remark');
  60.         $this->addSql('RENAME TABLE legal_entity_member_company TO member_company');
  61.         $this->addSql('ALTER TABLE legal_entity ADD COLUMN _discr VARCHAR(255)');
  62.         $this->addSql('UPDATE legal_entity SET _discr = "member" WHERE member = 1', ['member' => 'member']);
  63.         $this->addSql('UPDATE legal_entity SET _discr = "nonmember" WHERE member = 0', ['member' => 'member']);
  64.         $this->addSql('ALTER TABLE legal_entity DROP COLUMN member');
  65.         $this->addSql('ALTER TABLE `legal_entity` CHANGE `member_company_id` `company_id` INT(11) NULL DEFAULT NULL;');
  66.         $this->addSql('ALTER TABLE `non_member_order` CHANGE `number` `number` INT(11) NOT NULL;');
  67.     }
  68. }