diff --git a/migrations/Version20230911163930.php b/migrations/Version20230911163930.php deleted file mode 100644 index 90b09948f6..0000000000 --- a/migrations/Version20230911163930.php +++ /dev/null @@ -1,33 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); - - $this->addSql('ALTER TABLE mail_preferences ADD description VARCHAR(255) NOT NULL'); - $this->addSql('ALTER TABLE mail_preferences ADD newsletter BOOLEAN NOT NULL'); - } - - /** - * @param \Doctrine\DBAL\Schema\Schema $schema - * @return void - */ - public function down(Schema $schema) : void - { - $this->throwIrreversibleMigrationException(); - } -} diff --git a/migrations/Version20230911164846.php b/migrations/Version20230911164846.php deleted file mode 100644 index 1b5d6bf77b..0000000000 --- a/migrations/Version20230911164846.php +++ /dev/null @@ -1,32 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); - - $this->addSql('ALTER TABLE mail_preferences RENAME COLUMN newsletter TO is_newsletter'); - } - - /** - * @param \Doctrine\DBAL\Schema\Schema $schema - * @return void - */ - public function down(Schema $schema) : void - { - $this->throwIrreversibleMigrationException(); - } -} diff --git a/migrations/Version20230911170911.php b/migrations/Version20230911170911.php deleted file mode 100644 index c6014a5a2d..0000000000 --- a/migrations/Version20230911170911.php +++ /dev/null @@ -1,33 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); - - $this->addSql('ALTER TABLE mail_preferences ALTER description TYPE TEXT'); - $this->addSql('ALTER TABLE mail_preferences ALTER description DROP DEFAULT'); - } - - /** - * @param \Doctrine\DBAL\Schema\Schema $schema - * @return void - */ - public function down(Schema $schema) : void - { - $this->throwIrreversibleMigrationException(); - } -} diff --git a/migrations/Version20230922195128.php b/migrations/Version20230922195128.php new file mode 100644 index 0000000000..9d9755e7c1 --- /dev/null +++ b/migrations/Version20230922195128.php @@ -0,0 +1,45 @@ +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(); + } +}