<?php
declare(strict_types=1);
namespace CustomerOutstandingBundleMigrations;
use App\Services\ObjectSerialize;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\Uid\UuidV6;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221207100624 extends AbstractMigration
{
private ObjectSerialize $objectSerialize;
public function setObjectSerialize(ObjectSerialize $objectSerialize)
{
$this->objectSerialize = $objectSerialize;
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE customer_outstanding_bundle__customer_type (id INT AUTO_INCREMENT NOT NULL, customer_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)\', amount NUMERIC(20, 6) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_4CCAA5F89395C3F3 (customer_id), INDEX IDX_4CCAA5F8B03A8386 (created_by_id), INDEX IDX_4CCAA5F8896DBBDE (updated_by_id), INDEX IDX_4CCAA5F8C76F1F52 (deleted_by_id), 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 customer_outstanding_bundle__customer_type ADD CONSTRAINT FK_4CCAA5F89395C3F3 FOREIGN KEY (customer_id) REFERENCES customers_bundle__customer (id)');
$this->addSql('ALTER TABLE customer_outstanding_bundle__customer_type ADD CONSTRAINT FK_4CCAA5F8B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE customer_outstanding_bundle__customer_type ADD CONSTRAINT FK_4CCAA5F8896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE customer_outstanding_bundle__customer_type ADD CONSTRAINT FK_4CCAA5F8C76F1F52 FOREIGN KEY (deleted_by_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE customer_outstanding_bundle__customer_type DROP FOREIGN KEY FK_4CCAA5F89395C3F3');
$this->addSql('ALTER TABLE customer_outstanding_bundle__customer_type DROP FOREIGN KEY FK_4CCAA5F8B03A8386');
$this->addSql('ALTER TABLE customer_outstanding_bundle__customer_type DROP FOREIGN KEY FK_4CCAA5F8896DBBDE');
$this->addSql('ALTER TABLE customer_outstanding_bundle__customer_type DROP FOREIGN KEY FK_4CCAA5F8C76F1F52');
$this->addSql('DROP TABLE customer_outstanding_bundle__customer_type');
}
public function postUp(Schema $schema): void
{
parent::postUp($schema);
$now = (new \DateTime())->format('Y-m-d H:i:s');
$configurations = [
'customer_outstanding_bundle__enabled' => true
];
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
]);
}
}
}