From e482b4567a05afbd3a2481aaec4fc9a11704b54d Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sun, 12 Mar 2023 18:15:25 +0300 Subject: [PATCH] Doctrine migrations ported. --- config/packages/doctrine_migrations.yaml | 4 +++ .../Version20150528203127.php | 23 +++++++------ migrations/Version20151001210600.php | 28 +++++++++++++++ .../Version20160324002719.php | 23 ++++--------- .../Version20160324005746.php | 23 ++++--------- .../Version20160324011937.php | 23 ++++--------- .../Version20160325001415.php | 23 ++++--------- .../Version20160326030437.php | 23 ++++--------- .../Version20160328060523.php | 23 ++++--------- .../Version20160329035248.php | 23 ++++--------- .../Version20170105191821.php | 20 ++++------- .../Version20170108152129.php | 20 ++++------- .../Version20170108153353.php | 20 ++++------- .../Version20170116224555.php | 20 ++++------- .../Version20171104182713.php | 20 ++++------- .../Version20171106013937.php | 20 ++++------- .../Version20171106023155.php | 20 ++++------- .../Version20151001210600.php | 34 ------------------- 18 files changed, 142 insertions(+), 248 deletions(-) rename {old/app/DoctrineMigrations => migrations}/Version20150528203127.php (90%) create mode 100644 migrations/Version20151001210600.php rename {old/app/DoctrineMigrations => migrations}/Version20160324002719.php (50%) rename {old/app/DoctrineMigrations => migrations}/Version20160324005746.php (89%) rename {old/app/DoctrineMigrations => migrations}/Version20160324011937.php (50%) rename {old/app/DoctrineMigrations => migrations}/Version20160325001415.php (82%) rename {old/app/DoctrineMigrations => migrations}/Version20160326030437.php (78%) rename {old/app/DoctrineMigrations => migrations}/Version20160328060523.php (70%) rename {old/app/DoctrineMigrations => migrations}/Version20160329035248.php (50%) rename {old/app/DoctrineMigrations => migrations}/Version20170105191821.php (77%) rename {old/app/DoctrineMigrations => migrations}/Version20170108152129.php (61%) rename {old/app/DoctrineMigrations => migrations}/Version20170108153353.php (51%) rename {old/app/DoctrineMigrations => migrations}/Version20170116224555.php (55%) rename {old/app/DoctrineMigrations => migrations}/Version20171104182713.php (69%) rename {old/app/DoctrineMigrations => migrations}/Version20171106013937.php (58%) rename {old/app/DoctrineMigrations => migrations}/Version20171106023155.php (78%) delete mode 100644 old/app/DoctrineMigrations/Version20151001210600.php diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml index 29231d9..14d6654 100644 --- a/config/packages/doctrine_migrations.yaml +++ b/config/packages/doctrine_migrations.yaml @@ -4,3 +4,7 @@ doctrine_migrations: # as migrations classes should NOT be autoloaded 'DoctrineMigrations': '%kernel.project_dir%/migrations' enable_profiler: false + storage: + table_storage: + table_name: 'migration_versions' + check_database_platform: true diff --git a/old/app/DoctrineMigrations/Version20150528203127.php b/migrations/Version20150528203127.php similarity index 90% rename from old/app/DoctrineMigrations/Version20150528203127.php rename to migrations/Version20150528203127.php index 31b89a7..b2e4110 100644 --- a/old/app/DoctrineMigrations/Version20150528203127.php +++ b/migrations/Version20150528203127.php @@ -1,19 +1,23 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); @@ -37,10 +41,7 @@ class Version20150528203127 extends AbstractMigration $this->addSql('ALTER TABLE subscriptions.log ADD CONSTRAINT FK_22DA64DD7808B1AD FOREIGN KEY (subscriber_id) REFERENCES users.users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); diff --git a/migrations/Version20151001210600.php b/migrations/Version20151001210600.php new file mode 100644 index 0000000..3147c2b --- /dev/null +++ b/migrations/Version20151001210600.php @@ -0,0 +1,28 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('DROP INDEX users.uniq_338adfc4aa08cb10'); + } + + public function down(Schema $schema): void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('CREATE UNIQUE INDEX uniq_338adfc4aa08cb10 ON users.users (login)'); + } +} diff --git a/old/app/DoctrineMigrations/Version20160324002719.php b/migrations/Version20160324002719.php similarity index 50% rename from old/app/DoctrineMigrations/Version20160324002719.php rename to migrations/Version20160324002719.php index f0c638a..c5e86cf 100644 --- a/old/app/DoctrineMigrations/Version20160324002719.php +++ b/migrations/Version20160324002719.php @@ -1,32 +1,23 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE users.users ADD updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE users.users DROP updated_at'); diff --git a/old/app/DoctrineMigrations/Version20160324005746.php b/migrations/Version20160324005746.php similarity index 89% rename from old/app/DoctrineMigrations/Version20160324005746.php rename to migrations/Version20160324005746.php index 79f0ade..3484c59 100644 --- a/old/app/DoctrineMigrations/Version20160324005746.php +++ b/migrations/Version20160324005746.php @@ -1,21 +1,16 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SCHEMA IF NOT EXISTS posts'); @@ -45,12 +40,8 @@ class Version20160324005746 extends AbstractMigration $this->addSql('ALTER TABLE posts.posts_tags ADD CONSTRAINT FK_7870CC82BAD26311 FOREIGN KEY (tag_id) REFERENCES posts.tags (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE posts.comments DROP CONSTRAINT FK_62899975727ACA70'); diff --git a/old/app/DoctrineMigrations/Version20160324011937.php b/migrations/Version20160324011937.php similarity index 50% rename from old/app/DoctrineMigrations/Version20160324011937.php rename to migrations/Version20160324011937.php index 6b4da45..f044897 100644 --- a/old/app/DoctrineMigrations/Version20160324011937.php +++ b/migrations/Version20160324011937.php @@ -1,32 +1,23 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE posts.posts ALTER updated_at DROP NOT NULL'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE posts.posts ALTER updated_at SET NOT NULL'); diff --git a/old/app/DoctrineMigrations/Version20160325001415.php b/migrations/Version20160325001415.php similarity index 82% rename from old/app/DoctrineMigrations/Version20160325001415.php rename to migrations/Version20160325001415.php index 3f38dca..33a05e2 100644 --- a/old/app/DoctrineMigrations/Version20160325001415.php +++ b/migrations/Version20160325001415.php @@ -1,21 +1,16 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SEQUENCE posts.files_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); @@ -33,12 +28,8 @@ class Version20160325001415 extends AbstractMigration $this->addSql('ALTER TABLE posts.posts_files ADD CONSTRAINT FK_D799EBF093CB796C FOREIGN KEY (file_id) REFERENCES posts.files (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE posts.comments_files DROP CONSTRAINT FK_D0F6932993CB796C'); diff --git a/old/app/DoctrineMigrations/Version20160326030437.php b/migrations/Version20160326030437.php similarity index 78% rename from old/app/DoctrineMigrations/Version20160326030437.php rename to migrations/Version20160326030437.php index 4f0291d..4cb5661 100644 --- a/old/app/DoctrineMigrations/Version20160326030437.php +++ b/migrations/Version20160326030437.php @@ -1,21 +1,16 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE posts.comments ALTER post_id TYPE TEXT'); @@ -30,12 +25,8 @@ class Version20160326030437 extends AbstractMigration $this->addSql('CREATE UNIQUE INDEX UNIQ_744CC52C68EA44FC ON posts.files (remote_url)'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE posts.comments ALTER post_id TYPE VARCHAR(16)'); diff --git a/old/app/DoctrineMigrations/Version20160328060523.php b/migrations/Version20160328060523.php similarity index 70% rename from old/app/DoctrineMigrations/Version20160328060523.php rename to migrations/Version20160328060523.php index 1b60693..31a8f21 100644 --- a/old/app/DoctrineMigrations/Version20160328060523.php +++ b/migrations/Version20160328060523.php @@ -1,21 +1,16 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE SEQUENCE users.rename_log_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); @@ -26,12 +21,8 @@ class Version20160328060523 extends AbstractMigration $this->addSql('ALTER TABLE users.rename_log ADD CONSTRAINT FK_10D64DDA76ED395 FOREIGN KEY (user_id) REFERENCES users.users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP SEQUENCE users.rename_log_id_seq CASCADE'); diff --git a/old/app/DoctrineMigrations/Version20160329035248.php b/migrations/Version20160329035248.php similarity index 50% rename from old/app/DoctrineMigrations/Version20160329035248.php rename to migrations/Version20160329035248.php index 5ac9be5..781b59e 100644 --- a/old/app/DoctrineMigrations/Version20160329035248.php +++ b/migrations/Version20160329035248.php @@ -1,32 +1,23 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE users.rename_log DROP new_login'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE users.rename_log ADD new_login TEXT DEFAULT \'\''); diff --git a/old/app/DoctrineMigrations/Version20170105191821.php b/migrations/Version20170105191821.php similarity index 77% rename from old/app/DoctrineMigrations/Version20170105191821.php rename to migrations/Version20170105191821.php index 5eb5559..3a75673 100644 --- a/old/app/DoctrineMigrations/Version20170105191821.php +++ b/migrations/Version20170105191821.php @@ -1,21 +1,19 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE TABLE users.telegram_accounts (account_id INT NOT NULL, user_id INT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, linked_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, first_name TEXT NOT NULL, last_name TEXT DEFAULT NULL, username TEXT DEFAULT NULL, private_chat_id BIGINT DEFAULT NULL, subscriber_notification BOOLEAN NOT NULL, rename_notification BOOLEAN NOT NULL, PRIMARY KEY(account_id))'); @@ -25,12 +23,8 @@ class Version20170105191821 extends AbstractMigration $this->addSql('ALTER TABLE users.telegram_accounts ADD CONSTRAINT FK_1EDB9B25A76ED395 FOREIGN KEY (user_id) REFERENCES users.users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP TABLE users.telegram_accounts'); diff --git a/old/app/DoctrineMigrations/Version20170108152129.php b/migrations/Version20170108152129.php similarity index 61% rename from old/app/DoctrineMigrations/Version20170108152129.php rename to migrations/Version20170108152129.php index 39fbe00..06c0cd5 100644 --- a/old/app/DoctrineMigrations/Version20170108152129.php +++ b/migrations/Version20170108152129.php @@ -1,30 +1,24 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER INDEX subscriptions.idx_22da64ddf675f31b RENAME TO author_idx'); $this->addSql('ALTER INDEX subscriptions.idx_22da64dd7808b1ad RENAME TO subscriber_idx'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER INDEX subscriptions.subscriber_idx RENAME TO idx_22da64dd7808b1ad'); diff --git a/old/app/DoctrineMigrations/Version20170108153353.php b/migrations/Version20170108153353.php similarity index 51% rename from old/app/DoctrineMigrations/Version20170108153353.php rename to migrations/Version20170108153353.php index fff0982..a61fedd 100644 --- a/old/app/DoctrineMigrations/Version20170108153353.php +++ b/migrations/Version20170108153353.php @@ -1,29 +1,23 @@ abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE INDEX idx_tag_text ON posts.tags (text)'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP INDEX posts.idx_tag_text'); diff --git a/old/app/DoctrineMigrations/Version20170116224555.php b/migrations/Version20170116224555.php similarity index 55% rename from old/app/DoctrineMigrations/Version20170116224555.php rename to migrations/Version20170116224555.php index f2fb05a..4cc36f0 100644 --- a/old/app/DoctrineMigrations/Version20170116224555.php +++ b/migrations/Version20170116224555.php @@ -1,32 +1,26 @@ abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE users.users ADD is_removed BOOLEAN DEFAULT FALSE NOT NULL'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE users.users DROP is_removed'); diff --git a/old/app/DoctrineMigrations/Version20171104182713.php b/migrations/Version20171104182713.php similarity index 69% rename from old/app/DoctrineMigrations/Version20171104182713.php rename to migrations/Version20171104182713.php index 21130e5..c9e5f65 100644 --- a/old/app/DoctrineMigrations/Version20171104182713.php +++ b/migrations/Version20171104182713.php @@ -1,21 +1,19 @@ abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER TABLE users.users ADD public BOOLEAN DEFAULT FALSE NOT NULL'); @@ -24,12 +22,8 @@ class Version20171104182713 extends AbstractMigration $this->addSql('CREATE INDEX idx_user_removed ON users.users (is_removed)'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP INDEX users.idx_user_public'); diff --git a/old/app/DoctrineMigrations/Version20171106013937.php b/migrations/Version20171106013937.php similarity index 58% rename from old/app/DoctrineMigrations/Version20171106013937.php rename to migrations/Version20171106013937.php index 7100436..0b0079e 100644 --- a/old/app/DoctrineMigrations/Version20171106013937.php +++ b/migrations/Version20171106013937.php @@ -1,32 +1,26 @@ abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('DROP INDEX subscriptions.subscription_unique'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE UNIQUE INDEX subscription_unique ON subscriptions.subscriptions (author_id, subscriber_id)'); diff --git a/old/app/DoctrineMigrations/Version20171106023155.php b/migrations/Version20171106023155.php similarity index 78% rename from old/app/DoctrineMigrations/Version20171106023155.php rename to migrations/Version20171106023155.php index e9110aa..a98cc0c 100644 --- a/old/app/DoctrineMigrations/Version20171106023155.php +++ b/migrations/Version20171106023155.php @@ -1,21 +1,19 @@ abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('ALTER INDEX subscriptions.author_idx RENAME TO idx_subscription_author'); @@ -26,12 +24,8 @@ class Version20171106023155 extends AbstractMigration $this->addSql('DROP INDEX posts.idx_tag_text'); } - /** - * @param Schema $schema - */ - public function down(Schema $schema) + public function down(Schema $schema): void { - // this down() migration is auto-generated, please modify it to your needs $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); $this->addSql('CREATE INDEX idx_tag_text ON posts.tags (text)'); diff --git a/old/app/DoctrineMigrations/Version20151001210600.php b/old/app/DoctrineMigrations/Version20151001210600.php deleted file mode 100644 index 101a533..0000000 --- a/old/app/DoctrineMigrations/Version20151001210600.php +++ /dev/null @@ -1,34 +0,0 @@ -abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); - - $this->addSql('DROP INDEX users.uniq_338adfc4aa08cb10'); - } - - /** - * @param Schema $schema - */ - public function down(Schema $schema) - { - // this down() migration is auto-generated, please modify it to your needs - $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); - - $this->addSql('CREATE UNIQUE INDEX uniq_338adfc4aa08cb10 ON users.users (login)'); - } -}