<?php
declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200609102733 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('RENAME TABLE non_member_billing_company TO legal_entity_billing_company');
$this->addSql('RENAME TABLE non_member_billing_contact_person TO legal_entity_billing_contact_person');
$this->addSql('RENAME TABLE non_member_contract TO legal_entity_contract');
$this->addSql('RENAME TABLE non_member_license_agreement TO legal_entity_license_agreement');
$this->addSql('RENAME TABLE non_member_order_invoice_item TO legal_entity_order_invoice_item');
$this->addSql('RENAME TABLE non_member_order_invoice_manual TO legal_entity_order_invoice_manual');
$this->addSql('RENAME TABLE non_member_order_invoice_manual_item TO legal_entity_order_invoice_manual_item');
$this->addSql('RENAME TABLE non_member_order_invoice_reminder TO legal_entity_order_invoice_reminder');
$this->addSql('RENAME TABLE non_member_order_invoice TO legal_entity_order_invoice');
$this->addSql('RENAME TABLE non_member_order TO legal_entity_order');
$this->addSql('RENAME TABLE non_member_order_line_dossiers TO legal_entity_order_line_dossiers');
$this->addSql('RENAME TABLE non_member_order_line_dossiers_pending TO legal_entity_order_line_dossiers_pending');
$this->addSql('RENAME TABLE non_member_order_line TO legal_entity_order_line');
$this->addSql('RENAME TABLE non_member_order_line_status TO legal_entity_order_line_status');
$this->addSql('RENAME TABLE non_member_order_reinvoicing_line TO legal_entity_order_reinvoicing_line');
$this->addSql('RENAME TABLE non_member_active_definition TO legal_entity_active_definition');
$this->addSql('RENAME TABLE non_member_cart_line TO legal_entity_cart_line');
$this->addSql('RENAME TABLE member_company_remark TO legal_entity_member_company_remark');
$this->addSql('RENAME TABLE member_company TO legal_entity_member_company');
$this->addSql('ALTER TABLE legal_entity ADD COLUMN member TINYINT(1)');
$this->addSql('ALTER TABLE `legal_entity` CHANGE `company_id` `member_company_id` INT(11) NULL DEFAULT NULL;');
$this->addSql('UPDATE legal_entity SET member = 1 WHERE _discr = :member', ['member' => 'member']);
$this->addSql('UPDATE legal_entity SET member = 0 WHERE _discr != :member', ['member' => 'member']);
$this->addSql('UPDATE legal_entity SET active_definition_id = null');
$this->addSql('ALTER TABLE `legal_entity` DROP COLUMN `_discr`');
$this->addSql('ALTER TABLE `legal_entity_order` CHANGE `number` `number` INT(11) NULL;');
}
public function down(Schema $schema): void
{
$this->addSql('RENAME TABLE legal_entity_billing_company TO non_member_billing_company');
$this->addSql('RENAME TABLE legal_entity_billing_contact_person TO non_member_billing_contact_person');
$this->addSql('RENAME TABLE legal_entity_contract TO non_member_contract');
$this->addSql('RENAME TABLE legal_entity_license_agreement TO non_member_license_agreement');
$this->addSql('RENAME TABLE legal_entity_order_invoice_item TO non_member_order_invoice_item');
$this->addSql('RENAME TABLE legal_entity_order_invoice_manual TO non_member_order_invoice_manual');
$this->addSql('RENAME TABLE legal_entity_order_invoice_manual_item TO non_member_order_invoice_manual_item');
$this->addSql('RENAME TABLE legal_entity_order_invoice_reminder TO non_member_order_invoice_reminder');
$this->addSql('RENAME TABLE legal_entity_order_invoice TO non_member_order_invoice');
$this->addSql('RENAME TABLE legal_entity_order TO non_member_order');
$this->addSql('RENAME TABLE legal_entity_order_line_dossiers TO non_member_order_line_dossiers');
$this->addSql('RENAME TABLE legal_entity_order_line_dossiers_pending TO non_member_order_line_dossiers_pending');
$this->addSql('RENAME TABLE legal_entity_order_line TO non_member_order_line');
$this->addSql('RENAME TABLE legal_entity_order_line_status TO non_member_order_line_status');
$this->addSql('RENAME TABLE legal_entity_order_reinvoicing_line TO non_member_order_reinvoicing_line');
$this->addSql('RENAME TABLE legal_entity_active_definition TO non_member_active_definition');
$this->addSql('RENAME TABLE legal_entity_cart_line TO non_member_cart_line');
$this->addSql('RENAME TABLE legal_entity_member_company_remark TO member_company_remark');
$this->addSql('RENAME TABLE legal_entity_member_company TO member_company');
$this->addSql('ALTER TABLE legal_entity ADD COLUMN _discr VARCHAR(255)');
$this->addSql('UPDATE legal_entity SET _discr = "member" WHERE member = 1', ['member' => 'member']);
$this->addSql('UPDATE legal_entity SET _discr = "nonmember" WHERE member = 0', ['member' => 'member']);
$this->addSql('ALTER TABLE legal_entity DROP COLUMN member');
$this->addSql('ALTER TABLE `legal_entity` CHANGE `member_company_id` `company_id` INT(11) NULL DEFAULT NULL;');
$this->addSql('ALTER TABLE `non_member_order` CHANGE `number` `number` INT(11) NOT NULL;');
}
}