<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20250603195107 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create fee and fee_category tables';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE fee (id UUID NOT NULL, fee_category_id UUID DEFAULT NULL, name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, price DOUBLE PRECISION DEFAULT NULL, is_multiple BOOLEAN NOT NULL, has_description BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_964964B59B9BF38C ON fee (fee_category_id)');
$this->addSql('COMMENT ON COLUMN fee.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN fee.fee_category_id IS \'(DC2Type:uuid)\'');
$this->addSql('CREATE TABLE fee_category (id UUID NOT NULL, name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN fee_category.id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE fee ADD CONSTRAINT FK_964964B59B9BF38C FOREIGN KEY (fee_category_id) REFERENCES fee_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE tree_to_remove_removal_reason ALTER tree_to_remove_id DROP DEFAULT');
$this->addSql('INSERT INTO fee_category (id, name, created_at) SELECT id, name, created_at FROM abap_payment_category');
$this->addSql('INSERT INTO fee (id, fee_category_id, name, created_at, price, is_multiple, has_description) SELECT id, payment_category_id, name, created_at, price, is_multiple, has_description FROM abap_payment_position');
}
public function down(Schema $schema): void
{
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE fee DROP CONSTRAINT FK_964964B59B9BF38C');
$this->addSql('DROP TABLE fee');
$this->addSql('DROP TABLE fee_category');
$this->addSql('ALTER TABLE tree_to_remove_removal_reason ALTER tree_to_remove_id SET DEFAULT \'gen_random_uuid()\'');
}
}