<?php
declare(strict_types=1);
namespace DhlBundleMigrations;
use App\Services\ObjectSerialize;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\Uid\UuidV6;
final class Version20221208083601 extends AbstractMigration
{
private ObjectSerialize $objectSerialize;
public function setObjectSerialize(ObjectSerialize $objectSerialize)
{
$this->objectSerialize = $objectSerialize;
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE dhl_bundle__package_type (id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\', created_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', updated_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', deleted_by_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\', name VARCHAR(255) NOT NULL, weight NUMERIC(20, 6) NOT NULL, width NUMERIC(20, 6) NOT NULL, height NUMERIC(20, 6) NOT NULL, depth NUMERIC(20, 6) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_E0041E8AB03A8386 (created_by_id), INDEX IDX_E0041E8A896DBBDE (updated_by_id), INDEX IDX_E0041E8AC76F1F52 (deleted_by_id), INDEX name (name), INDEX weight (weight), INDEX width (width), INDEX height (height), INDEX depth (depth), INDEX deleted_at (deleted_at), INDEX created_at (created_at), INDEX updated_at (updated_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE dhl_bundle__package_type ADD CONSTRAINT FK_E0041E8AB03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE dhl_bundle__package_type ADD CONSTRAINT FK_E0041E8A896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE dhl_bundle__package_type ADD CONSTRAINT FK_E0041E8AC76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE dhl_bundle__package_type DROP FOREIGN KEY FK_E0041E8AB03A8386');
$this->addSql('ALTER TABLE dhl_bundle__package_type DROP FOREIGN KEY FK_E0041E8A896DBBDE');
$this->addSql('ALTER TABLE dhl_bundle__package_type DROP FOREIGN KEY FK_E0041E8AC76F1F52');
$this->addSql('DROP TABLE dhl_bundle__package_type');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$now = (new \DateTime())->format('Y-m-d H:i:s');
$configurations = [
'dhl_bundle__limit_number_relays' => '30',
'dhl_bundle__package_content' => 'contenu du colis',
'dhl_bundle__shipper_country_name' => 'France'
];
foreach ($configurations as $configuration => $value) {
$this->connection->insert('configuration', [
'id' => (new UuidV6())->toBinary(),
'name' => $configuration,
'context_id' => null,
'value' => $this->objectSerialize->add((object) ['value' => $value]),
'created_at' => $now,
'updated_at' => $now
]);
}
$this->connection->insert('dhl_bundle__package_type', [
'id' => (new UuidV6())->toBinary(),
'name' => 'CARTON 25X20X15',
'weight' => '1',
'width' => '20',
'height' => '25',
'depth' => '15',
'created_at' => $now,
'updated_at' => $now
]);
shell_exec('bin/console do:fi:lo --append --group=dhl_bundle_logo_svg');
}
}