Skip to content

Commit

Permalink
migration dries fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrodevog committed Sep 22, 2023
1 parent 133d881 commit c264fdd
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 98 deletions.
33 changes: 0 additions & 33 deletions migrations/Version20230911163930.php

This file was deleted.

32 changes: 0 additions & 32 deletions migrations/Version20230911164846.php

This file was deleted.

33 changes: 0 additions & 33 deletions migrations/Version20230911170911.php

This file was deleted.

45 changes: 45 additions & 0 deletions migrations/Version20230922195128.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;

/**
* Version 20230922195128
*/
class Version20230922195128 extends \Doctrine\Migrations\AbstractMigration
{
/**
* @param \Doctrine\DBAL\Schema\Schema $schema
* @return void
*/
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('ALTER TABLE users_preferences DROP CONSTRAINT fk_1e849a072d737aef');
$this->addSql('ALTER TABLE mail_sections DROP CONSTRAINT fk_f64182d0fa9723a1');
$this->addSql('DROP SEQUENCE mail_sections_groups_id_seq CASCADE');
$this->addSql('DROP SEQUENCE mail_sections_id_seq CASCADE');
$this->addSql('DROP SEQUENCE users_preferences_id_seq CASCADE');
$this->addSql('CREATE TABLE mail_preferences (id BIGINT NOT NULL, name VARCHAR(255) NOT NULL, description TEXT NOT NULL, attribute VARCHAR(255) NOT NULL, default_value BOOLEAN NOT NULL, is_newsletter BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE users_preference_map (id BIGINT NOT NULL, person BIGINT DEFAULT NULL, preference BIGINT DEFAULT NULL, value BOOLEAN NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_1D7D890F34DCD176 ON users_preference_map (person)');
$this->addSql('CREATE INDEX IDX_1D7D890F5D69B053 ON users_preference_map (preference)');
$this->addSql('ALTER TABLE users_preference_map ADD CONSTRAINT FK_1D7D890F34DCD176 FOREIGN KEY (person) REFERENCES users_people_academic (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE users_preference_map ADD CONSTRAINT FK_1D7D890F5D69B053 FOREIGN KEY (preference) REFERENCES mail_preferences (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('DROP TABLE users_preferences');
$this->addSql('DROP TABLE mail_sections');
$this->addSql('DROP TABLE mail_sections_groups');
}

/**
* @param \Doctrine\DBAL\Schema\Schema $schema
* @return void
*/
public function down(Schema $schema) : void
{
$this->throwIrreversibleMigrationException();
}
}

0 comments on commit c264fdd

Please sign in to comment.