migrations/Version20250603195107.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20250603195107 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Create fee and fee_category tables';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $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))');
  15.         $this->addSql('CREATE INDEX IDX_964964B59B9BF38C ON fee (fee_category_id)');
  16.         $this->addSql('COMMENT ON COLUMN fee.id IS \'(DC2Type:uuid)\'');
  17.         $this->addSql('COMMENT ON COLUMN fee.fee_category_id IS \'(DC2Type:uuid)\'');
  18.         $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))');
  19.         $this->addSql('COMMENT ON COLUMN fee_category.id IS \'(DC2Type:uuid)\'');
  20.         $this->addSql('ALTER TABLE fee ADD CONSTRAINT FK_964964B59B9BF38C FOREIGN KEY (fee_category_id) REFERENCES fee_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  21.         $this->addSql('ALTER TABLE tree_to_remove_removal_reason ALTER tree_to_remove_id DROP DEFAULT');
  22.         $this->addSql('INSERT INTO fee_category (id, name, created_at) SELECT id, name, created_at FROM abap_payment_category');
  23.         $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');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         $this->addSql('CREATE SCHEMA public');
  28.         $this->addSql('ALTER TABLE fee DROP CONSTRAINT FK_964964B59B9BF38C');
  29.         $this->addSql('DROP TABLE fee');
  30.         $this->addSql('DROP TABLE fee_category');
  31.         $this->addSql('ALTER TABLE tree_to_remove_removal_reason ALTER tree_to_remove_id SET DEFAULT \'gen_random_uuid()\'');
  32.     }
  33. }