<?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 Version20200923120905 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE legal_entity_contract ADD document_date DATE DEFAULT NULL COMMENT \'(DC2Type:carbondate)\', ADD legacy_file_name VARCHAR(255) DEFAULT NULL, ADD legacy_file_path VARCHAR(255) DEFAULT NULL, ADD legacy_file_mime_type VARCHAR(255) DEFAULT NULL, ADD legacy_file_size INT DEFAULT NULL, ADD legacy_file_timestamp DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE acceptance_notification_sent acceptance_notification_sent DATE DEFAULT NULL COMMENT \'(DC2Type:carbondate)\', CHANGE accepted_at accepted_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE created_at created_at DATETIME NOT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE updated_at updated_at DATETIME NOT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE check_date check_date DATE DEFAULT NULL COMMENT \'(DC2Type:carbondate)\', CHANGE file_timestamp file_timestamp DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\'');
$this->addSql('INSERT INTO legal_entity_contract (legal_entity_id, order_id, accepted_by_id,force_acceptance, acceptance_notification_sent, accepted, accepted_ip, accepted_at, created_at, updated_at,legacy_file_name,legacy_file_path, legacy_file_mime_type, legacy_file_size, file_name, file_path, file_mime_type, file_size, document_date, legacy_file_timestamp, file_timestamp, dtype, acceptance_required )
SELECT legal_entity_id, order_id, accepted_by_id,force_acceptance, acceptance_notification_sent, accepted, accepted_ip, accepted_at, created_at, updated_at,legacy_file_name,legacy_file_path, legacy_file_mime_type, legacy_file_size, file_name, file_path, file_mime_type, file_size, document_date, legacy_file_timestamp, file_timestamp,\'licenseagreement\', 1 FROM legal_entity_license_agreement');
$this->addSql('UPDATE legal_entity_contract SET legal_entity_contract.document_date = legal_entity_contract.created_at WHERE legal_entity_contract.document_date IS NULL ');
$this->addSql('DROP TABLE legal_entity_license_agreement');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE legal_entity_license_agreement (id INT AUTO_INCREMENT NOT NULL, legal_entity_id INT DEFAULT NULL, order_id INT DEFAULT NULL, accepted_by_id INT DEFAULT NULL, force_acceptance TINYINT(1) NOT NULL, acceptance_notification_sent DATE DEFAULT NULL COMMENT \'(DC2Type:carbondate)\', accepted TINYINT(1) NOT NULL, accepted_ip VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, accepted_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:carbondatetime)\', updated_at DATETIME NOT NULL COMMENT \'(DC2Type:carbondatetime)\', legacy_file_name VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, legacy_file_path VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, legacy_file_mime_type VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, legacy_file_size INT DEFAULT NULL, file_name VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, file_path VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, file_mime_type VARCHAR(255) DEFAULT NULL COLLATE utf8mb4_unicode_ci, file_size INT DEFAULT NULL, document_date DATE DEFAULT NULL COMMENT \'(DC2Type:carbondate)\', legacy_file_timestamp DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\', file_timestamp DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\', INDEX IDX_10C7FEDF8D9F6D38 (order_id), INDEX IDX_10C7FEDF20F699D9 (accepted_by_id), UNIQUE INDEX UNIQ_10C7FEDF6DEC420C (legal_entity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('INSERT INTO legal_entity_license_agreement (legal_entity_id, order_id, accepted_by_id,force_acceptance, acceptance_notification_sent, accepted, accepted_ip, accepted_at, created_at, updated_at,legacy_file_name,legacy_file_path, legacy_file_mime_type, legacy_file_size, file_name, file_path, file_mime_type, file_size, document_date, legacy_file_timestamp, file_timestamp)
SELECT legal_entity_id, order_id, accepted_by_id,force_acceptance, acceptance_notification_sent, accepted, accepted_ip, accepted_at, created_at, updated_at,legacy_file_name,legacy_file_path, legacy_file_mime_type, legacy_file_size, file_name, file_path, file_mime_type, file_size, document_date, legacy_file_timestamp, file_timestamp FROM legal_entity_contract WHERE discr = licenseagreement');
$this->addSql('ALTER TABLE legal_entity_contract DROP document_date, DROP legacy_file_name, DROP legacy_file_path, DROP legacy_file_mime_type, DROP legacy_file_size, DROP legacy_file_timestamp, CHANGE acceptance_notification_sent acceptance_notification_sent DATE DEFAULT NULL COMMENT \'(DC2Type:carbondate)\', CHANGE accepted_at accepted_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE created_at created_at DATETIME NOT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE updated_at updated_at DATETIME NOT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE file_timestamp file_timestamp DATETIME DEFAULT NULL COMMENT \'(DC2Type:carbondatetime)\', CHANGE check_date check_date DATE DEFAULT NULL COMMENT \'(DC2Type:carbondate)\'');
}
}