DX: [Address] fix inconsistencies between doctrine mapping and sql schema

DX: [Address] fix inconsistencies between doctrine mapping and sql schema

Fixed: Address vue module do now set empty value to empty string instead of null

DX: fixed AddressReferenceBaseImporterTest
This commit is contained in:
2023-03-06 16:18:15 +01:00
parent 8e0d144dd1
commit c9fe5a393f
8 changed files with 305 additions and 157 deletions

View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230306151218 extends AbstractMigration
{
public function getDescription(): string
{
return 'fix inconsistencies in chill_main_address_reference table';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refid TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refid SET DEFAULT \'\'');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET street = \'\' WHERE street IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET streetnumber = \'\' WHERE streetnumber IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET municipalitycode = \'\' WHERE municipalitycode IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET source = \'\' WHERE source IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source SET NOT NULL');
}
public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException('not double-checked');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refId TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refId DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber DROP NOT NULL');
}
}