From f6adbc143ac496e6ce055efe6736e55a6e69f2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 11:33:51 +0100 Subject: [PATCH 01/12] Add Doctrine migration for initial schema --- composer.json | 6 ++- migrations/Doctrine/Version030000.php | 74 +++++++++++++++++++++++++++ migrations/doctrine.yaml | 7 +++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 migrations/Doctrine/Version030000.php create mode 100644 migrations/doctrine.yaml diff --git a/composer.json b/composer.json index 4e014f75..78dd6e89 100644 --- a/composer.json +++ b/composer.json @@ -51,10 +51,14 @@ "phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-phpunit": "^1.3" }, + "suggest": { + "doctrine/doctrine-migrations-bundle": "To create the database tables with the shipped migrations" + }, "autoload": { "psr-4": { "Netgen\\RemoteMedia\\": "lib/", - "Netgen\\Bundle\\RemoteMediaBundle\\": "bundle/" + "Netgen\\Bundle\\RemoteMediaBundle\\": "bundle/", + "Netgen\\RemoteMedia\\Migrations\\": "migrations/" } }, "autoload-dev": { diff --git a/migrations/Doctrine/Version030000.php b/migrations/Doctrine/Version030000.php new file mode 100644 index 00000000..424f0ca7 --- /dev/null +++ b/migrations/Doctrine/Version030000.php @@ -0,0 +1,74 @@ +connection->getDatabasePlatform(); + + $this->abortIf( + !is_a($platform, 'Doctrine\DBAL\Platforms\AbstractMySQLPlatform') + && !is_a($platform, 'Doctrine\DBAL\Platforms\MySqlPlatform'), + 'Migration can only be executed safely on MySQL.', + ); + + // ngrm_remote_resource table + + $this->addSql( + <<<'EOT' + CREATE TABLE ngrm_remote_resource ( + id int NOT NULL AUTO_INCREMENT, + remote_id varchar(255) NOT NULL, + type varchar(100) NOT NULL, + url varchar(255) NOT NULL, + name varchar(255) NOT NULL, + original_filename varchar(255) NOT NULL, + md5 varchar(64) NOT NULL, + version varchar(100) DEFAULT NULL, + folder longtext COMMENT '(DC2Type:object)', + visibility varchar(100) NOT NULL, + size int NOT NULL, + alt_text text, + caption text, + tags longtext COMMENT '(DC2Type:array)', + metadata longtext COMMENT '(DC2Type:array)', + context longtext COMMENT '(DC2Type:array)', + created_at datetime NOT NULL COMMENT '(DC2Type:datetime_immutable)', + updated_at datetime NOT NULL COMMENT '(DC2Type:datetime_immutable)', + PRIMARY KEY (id), + UNIQUE KEY UNIQ_4B1F1DB42A3E9C94 (remote_id) + ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_unicode_ci + EOT + ); + + // ngrm_remote_resource_location table + + $this->addSql( + <<<'EOT' + CREATE TABLE ngrm_remote_resource_location ( + id int NOT NULL AUTO_INCREMENT, + remote_resource_id int DEFAULT NULL, + source varchar(255) DEFAULT NULL, + crop_settings longtext NOT NULL COMMENT '(DC2Type:array)', + watermark_text text, + created_at datetime NOT NULL COMMENT '(DC2Type:datetime_immutable)', + updated_at datetime NOT NULL COMMENT '(DC2Type:datetime_immutable)', + PRIMARY KEY (id), + KEY IDX_76616F4846147E03 (remote_resource_id), + CONSTRAINT FK_76616F4846147E03 FOREIGN KEY (remote_resource_id) + REFERENCES ngrm_remote_resource (id) ON DELETE CASCADE + ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE utf8mb4_unicode_ci + EOT + ); + } +} diff --git a/migrations/doctrine.yaml b/migrations/doctrine.yaml new file mode 100644 index 00000000..baecdf55 --- /dev/null +++ b/migrations/doctrine.yaml @@ -0,0 +1,7 @@ +migrations_paths: + Netgen\RemoteMedia\Migrations\Doctrine: Doctrine + +table_storage: + table_name: ngrm_migration_versions + +transactional: false From 0143fc348e4258750a66995834487f0782dd7f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 11:34:10 +0100 Subject: [PATCH 02/12] Document database migrations --- docs/CHANGELOG.md | 3 ++- docs/INSTALL.md | 11 +++++++++++ docs/UPGRADE.md | 13 +++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 94bf0986..d42d09aa 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,7 +8,7 @@ * `netgen/open-graph-bundle` is no longer supported and the Open Graph handler is removed * requires PHP 8.1+, Symfony 5.4 or 6.2+ (Symfony 7 is excluded by the Composer constraints), `doctrine/orm` 2.10+, `doctrine/doctrine-bundle` 2.4+ and `cloudinary/cloudinary_php` 2.9+ (Cloudinary SDK v1 is no longer supported) * Composer package type is now `symfony-bundle` (was `ezplatform-bundle`) and all non-bundle code lives in the new `Netgen\RemoteMedia\` namespace (`lib/`) -* the `ngremotemedia_field_link` table and the `RemoteMediaFieldLink` entity are removed, resources are stored in the new `ngrm_remote_resource` and `ngrm_remote_resource_location` tables (Doctrine XML mappings), no Doctrine migrations are shipped and v2 data is not migrated automatically +* the `ngremotemedia_field_link` table and the `RemoteMediaFieldLink` entity are removed, resources are stored in the new `ngrm_remote_resource` and `ngrm_remote_resource_location` tables (Doctrine XML mappings) created by the shipped Doctrine migration `Version030000`, v2 data is not migrated automatically * `Netgen\Bundle\RemoteMediaBundle\Core\FieldType\RemoteMedia\Value` is replaced by `Netgen\RemoteMedia\API\Values\RemoteResource` (identified by `remoteId`) and `RemoteResourceLocation` (crop settings, watermark text, source), `Variation` is replaced by `RemoteResourceVariation` * `Provider\Cloudinary\Search\Query` and `Result` are replaced by `Netgen\RemoteMedia\API\Search\Query` and `Result` (`getResults()` is now `getResources()` and returns `RemoteResource` objects) * `RemoteMediaProvider` is replaced by `Netgen\RemoteMedia\API\ProviderInterface` (service `netgen_remote_media.provider`), its methods take `RemoteResource` / `RemoteResourceLocation` objects @@ -25,6 +25,7 @@ ### Added * `cloudinary.folder_mode` option (`dynamic` / `fixed`) with support for both Cloudinary folder modes +* Doctrine migration which creates the `ngrm_remote_resource` and `ngrm_remote_resource_location` tables, see [installation instructions](INSTALL.md#database) * `cloudinary.use_asset_folder_as_public_id_prefix` option which prefixes the public ID with the asset folder in `dynamic` folder mode, so the same file can be uploaded to different folders * `cloudinary.append_extension`, `cloudinary.unique_filenames`, `cloudinary.cache_requests`, `cloudinary.log_requests` and `cloudinary.encryption_key` options * `named_objects` configuration with `ngrm_named_remote_resource` and `ngrm_named_remote_resource_location` Twig functions diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 243dd73b..04d75b15 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -176,6 +176,17 @@ netgen_remote_media: resource: "@NetgenRemoteMediaBundle/Resources/config/routing.yml" ``` +## Database + +The bundle ships a Doctrine migration which creates its database tables. It requires MySQL or MariaDB and `doctrine/doctrine-migrations-bundle`: + +``` +composer require doctrine/doctrine-migrations-bundle +php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml +``` + +Run this migration first: the tables of `netgen/layouts-remote-media` and `netgen/remote-media-ibexa` reference `ngrm_remote_resource_location`. + ## Configure Cloudinary webhook notifications (optional) If you want to be able to manage resources through Cloudinary interface as well, you might want to configure the [Cloudinary webhook notifications](Cloudinary/WEBHOOK_NOTIFICATIONS.md). Read more on the link. diff --git a/docs/UPGRADE.md b/docs/UPGRADE.md index 2097e3cb..d34be5f9 100644 --- a/docs/UPGRADE.md +++ b/docs/UPGRADE.md @@ -1,6 +1,19 @@ Netgen Remote Media Bundle upgrade instructions =============================================== +Upgrade to 3.0 (database migrations) +------------------------------------ + +### Database migrations + +The database tables are now created by a Doctrine migration shipped with the bundle. If you already have the tables (created with `doctrine:schema:update`), mark the migration as executed instead of running it: + +``` +php bin/console doctrine:migrations:version 'Netgen\RemoteMedia\Migrations\Doctrine\Version030000' --add --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml +``` + +New installs only need to run `doctrine:migrations:migrate` as described in the installation instructions. + Upgrade from 2.0 to 3.0 ----------------------- From 968dd6c90673d734a9e40ea08d4023ebe456b650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 11:41:18 +0100 Subject: [PATCH 03/12] Remove dependent package note from install instructions --- docs/INSTALL.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 04d75b15..d30a6243 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -185,8 +185,6 @@ composer require doctrine/doctrine-migrations-bundle php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` -Run this migration first: the tables of `netgen/layouts-remote-media` and `netgen/remote-media-ibexa` reference `ngrm_remote_resource_location`. - ## Configure Cloudinary webhook notifications (optional) If you want to be able to manage resources through Cloudinary interface as well, you might want to configure the [Cloudinary webhook notifications](Cloudinary/WEBHOOK_NOTIFICATIONS.md). Read more on the link. From 1cdc502a93d83f18f2f89585b1e69242d71de24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 11:44:19 +0100 Subject: [PATCH 04/12] Simplify platform check in initial migration --- migrations/Doctrine/Version030000.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/migrations/Doctrine/Version030000.php b/migrations/Doctrine/Version030000.php index 424f0ca7..f696a936 100644 --- a/migrations/Doctrine/Version030000.php +++ b/migrations/Doctrine/Version030000.php @@ -7,20 +7,11 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -use function is_a; - final class Version030000 extends AbstractMigration { public function up(Schema $schema): void { - // DBAL 3 has AbstractMySQLPlatform (MySQL and MariaDB), DBAL 2 has MySqlPlatform. - $platform = $this->connection->getDatabasePlatform(); - - $this->abortIf( - !is_a($platform, 'Doctrine\DBAL\Platforms\AbstractMySQLPlatform') - && !is_a($platform, 'Doctrine\DBAL\Platforms\MySqlPlatform'), - 'Migration can only be executed safely on MySQL.', - ); + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on MySQL.'); // ngrm_remote_resource table From 76d727cbafebe8edd41c7d24f1088a5bb4d0d47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 11:49:10 +0100 Subject: [PATCH 05/12] Require Doctrine migrations bundle --- composer.json | 4 +--- docs/INSTALL.md | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 78dd6e89..4dba01a8 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ "symfony/serializer": "^5.4 || ^6.2", "symfony/translation": "^5.4 || ^6.2", "doctrine/doctrine-bundle": "^2.4", + "doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/orm": "^2.10" }, "require-dev": { @@ -51,9 +52,6 @@ "phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-phpunit": "^1.3" }, - "suggest": { - "doctrine/doctrine-migrations-bundle": "To create the database tables with the shipped migrations" - }, "autoload": { "psr-4": { "Netgen\\RemoteMedia\\": "lib/", diff --git a/docs/INSTALL.md b/docs/INSTALL.md index d30a6243..6be7b750 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -178,10 +178,9 @@ netgen_remote_media: ## Database -The bundle ships a Doctrine migration which creates its database tables. It requires MySQL or MariaDB and `doctrine/doctrine-migrations-bundle`: +The bundle ships a Doctrine migration which creates its database tables. It requires MySQL or MariaDB: ``` -composer require doctrine/doctrine-migrations-bundle php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` From 987ec10b42dc6c109d391c149ed1d9ec9999eb08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 12:08:00 +0100 Subject: [PATCH 06/12] Remove table comments from initial migration --- migrations/Doctrine/Version030000.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migrations/Doctrine/Version030000.php b/migrations/Doctrine/Version030000.php index f696a936..1461566e 100644 --- a/migrations/Doctrine/Version030000.php +++ b/migrations/Doctrine/Version030000.php @@ -13,8 +13,6 @@ public function up(Schema $schema): void { $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on MySQL.'); - // ngrm_remote_resource table - $this->addSql( <<<'EOT' CREATE TABLE ngrm_remote_resource ( @@ -42,8 +40,6 @@ public function up(Schema $schema): void EOT ); - // ngrm_remote_resource_location table - $this->addSql( <<<'EOT' CREATE TABLE ngrm_remote_resource_location ( From b7823f311fd36f422d1e059a2b0b6c5da4421e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 12:11:21 +0100 Subject: [PATCH 07/12] Explain running migrations in upgrade instructions --- docs/UPGRADE.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/UPGRADE.md b/docs/UPGRADE.md index d34be5f9..345dfbbe 100644 --- a/docs/UPGRADE.md +++ b/docs/UPGRADE.md @@ -6,13 +6,18 @@ Upgrade to 3.0 (database migrations) ### Database migrations -The database tables are now created by a Doctrine migration shipped with the bundle. If you already have the tables (created with `doctrine:schema:update`), mark the migration as executed instead of running it: +The bundle now ships Doctrine migrations for its database tables. Run them with: ``` -php bin/console doctrine:migrations:version 'Netgen\RemoteMedia\Migrations\Doctrine\Version030000' --add --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml +php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` -New installs only need to run `doctrine:migrations:migrate` as described in the installation instructions. +If the tables already exist (for example, created with `doctrine:schema:update`), the initial migration fails. Mark it as executed and run the migrations again to execute the remaining ones: + +``` +php bin/console doctrine:migrations:version 'Netgen\RemoteMedia\Migrations\Doctrine\Version030000' --add --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml +php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml +``` Upgrade from 2.0 to 3.0 ----------------------- From 1374976371b1e860ea83c9f548a00ad6f228c969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 12:14:26 +0100 Subject: [PATCH 08/12] Mention running migrations after updates --- docs/INSTALL.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 6be7b750..c533c3a1 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -184,6 +184,8 @@ The bundle ships a Doctrine migration which creates its database tables. It requ php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` +Run this command after every update of the bundle, for example as part of your deployment, so new migrations are applied. + ## Configure Cloudinary webhook notifications (optional) If you want to be able to manage resources through Cloudinary interface as well, you might want to configure the [Cloudinary webhook notifications](Cloudinary/WEBHOOK_NOTIFICATIONS.md). Read more on the link. From 1442636db98cea9f7b31867a82b6973399c403fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Tue, 27 Oct 2026 12:36:53 +0100 Subject: [PATCH 09/12] Fix command for marking initial migration as executed --- docs/UPGRADE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/UPGRADE.md b/docs/UPGRADE.md index 345dfbbe..8a349cd1 100644 --- a/docs/UPGRADE.md +++ b/docs/UPGRADE.md @@ -12,9 +12,10 @@ The bundle now ships Doctrine migrations for its database tables. Run them with: php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` -If the tables already exist (for example, created with `doctrine:schema:update`), the initial migration fails. Mark it as executed and run the migrations again to execute the remaining ones: +If the tables already exist (for example, created with `doctrine:schema:update`), the initial migration fails. Create the migration version table, mark the initial migration as executed and run the migrations again to execute the remaining ones (the `version` command does not create the version table by itself, so `sync-metadata-storage` has to run first): ``` +php bin/console doctrine:migrations:sync-metadata-storage --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml php bin/console doctrine:migrations:version 'Netgen\RemoteMedia\Migrations\Doctrine\Version030000' --add --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` From a6e105e4793d854fa4c885a6a4d446d4e72a13ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Wed, 28 Oct 2026 15:01:21 +0100 Subject: [PATCH 10/12] Add down migration for initial schema --- migrations/Doctrine/Version030000.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/migrations/Doctrine/Version030000.php b/migrations/Doctrine/Version030000.php index 1461566e..817a31cb 100644 --- a/migrations/Doctrine/Version030000.php +++ b/migrations/Doctrine/Version030000.php @@ -58,4 +58,12 @@ public function up(Schema $schema): void EOT ); } + + public function down(Schema $schema): void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on MySQL.'); + + $this->addSql('DROP TABLE ngrm_remote_resource_location'); + $this->addSql('DROP TABLE ngrm_remote_resource'); + } } From 0eac27bacb565a708992a71ec7d2f8c553a8e150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Wed, 28 Oct 2026 15:01:27 +0100 Subject: [PATCH 11/12] Document running migrations from Composer scripts --- docs/CHANGELOG.md | 1 + docs/INSTALL.md | 12 +++++++++++- docs/UPGRADE.md | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d42d09aa..8017431e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -26,6 +26,7 @@ * `cloudinary.folder_mode` option (`dynamic` / `fixed`) with support for both Cloudinary folder modes * Doctrine migration which creates the `ngrm_remote_resource` and `ngrm_remote_resource_location` tables, see [installation instructions](INSTALL.md#database) +* `doctrine/doctrine-migrations-bundle` is now required * `cloudinary.use_asset_folder_as_public_id_prefix` option which prefixes the public ID with the asset folder in `dynamic` folder mode, so the same file can be uploaded to different folders * `cloudinary.append_extension`, `cloudinary.unique_filenames`, `cloudinary.cache_requests`, `cloudinary.log_requests` and `cloudinary.encryption_key` options * `named_objects` configuration with `ngrm_named_remote_resource` and `ngrm_named_remote_resource_location` Twig functions diff --git a/docs/INSTALL.md b/docs/INSTALL.md index c533c3a1..04d90e54 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -184,7 +184,17 @@ The bundle ships a Doctrine migration which creates its database tables. It requ php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` -Run this command after every update of the bundle, for example as part of your deployment, so new migrations are applied. +Run this command after every update of the bundle, for example as part of your deployment, so new migrations are applied. You can also run it automatically by adding it to the Composer `post-update-cmd` (and/or `post-install-cmd`) scripts in your `composer.json`: + +```json +{ + "scripts": { + "post-update-cmd": [ + "@php bin/console doctrine:migrations:migrate --no-interaction --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml" + ] + } +} +``` ## Configure Cloudinary webhook notifications (optional) diff --git a/docs/UPGRADE.md b/docs/UPGRADE.md index 8a349cd1..6d16da3d 100644 --- a/docs/UPGRADE.md +++ b/docs/UPGRADE.md @@ -12,7 +12,7 @@ The bundle now ships Doctrine migrations for its database tables. Run them with: php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml ``` -If the tables already exist (for example, created with `doctrine:schema:update`), the initial migration fails. Create the migration version table, mark the initial migration as executed and run the migrations again to execute the remaining ones (the `version` command does not create the version table by itself, so `sync-metadata-storage` has to run first): +If the tables already exist (for example, created with `doctrine:schema:update`), the initial migration fails. Create the migration version table, mark the initial migration as executed and run the migrations again (the `version` command does not create the version table by itself, so `sync-metadata-storage` has to run first): ``` php bin/console doctrine:migrations:sync-metadata-storage --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml From ed6557d11369a5f48e5050376bff8b70558e2fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20=C4=8Cupi=C4=87?= Date: Thu, 29 Oct 2026 10:06:52 +0100 Subject: [PATCH 12/12] Align documentation with shipped migrations --- docs/CHANGELOG.md | 2 +- docs/UPGRADE.md | 35 ++++++++++++++--------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8017431e..791d4bca 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -25,7 +25,7 @@ ### Added * `cloudinary.folder_mode` option (`dynamic` / `fixed`) with support for both Cloudinary folder modes -* Doctrine migration which creates the `ngrm_remote_resource` and `ngrm_remote_resource_location` tables, see [installation instructions](INSTALL.md#database) +* Doctrine migration `Version030000` which creates the `ngrm_remote_resource` and `ngrm_remote_resource_location` tables, with its own configuration `migrations/doctrine.yaml` and version table `ngrm_migration_versions`, see [installation instructions](INSTALL.md#database) * `doctrine/doctrine-migrations-bundle` is now required * `cloudinary.use_asset_folder_as_public_id_prefix` option which prefixes the public ID with the asset folder in `dynamic` folder mode, so the same file can be uploaded to different folders * `cloudinary.append_extension`, `cloudinary.unique_filenames`, `cloudinary.cache_requests`, `cloudinary.log_requests` and `cloudinary.encryption_key` options diff --git a/docs/UPGRADE.md b/docs/UPGRADE.md index 6d16da3d..a0bd451f 100644 --- a/docs/UPGRADE.md +++ b/docs/UPGRADE.md @@ -1,25 +1,6 @@ Netgen Remote Media Bundle upgrade instructions =============================================== -Upgrade to 3.0 (database migrations) ------------------------------------- - -### Database migrations - -The bundle now ships Doctrine migrations for its database tables. Run them with: - -``` -php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml -``` - -If the tables already exist (for example, created with `doctrine:schema:update`), the initial migration fails. Create the migration version table, mark the initial migration as executed and run the migrations again (the `version` command does not create the version table by itself, so `sync-metadata-storage` has to run first): - -``` -php bin/console doctrine:migrations:sync-metadata-storage --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml -php bin/console doctrine:migrations:version 'Netgen\RemoteMedia\Migrations\Doctrine\Version030000' --add --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml -php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml -``` - Upgrade from 2.0 to 3.0 ----------------------- @@ -27,7 +8,7 @@ Version 3.0 is a major release. The bundle is decoupled from eZ / Ibexa and cont ### Upgrade `composer.json` -* Require `netgen/remote-media-bundle` `^3.0` and run `composer update`. +* Require `netgen/remote-media-bundle` `^3.0` and run `composer update`. The bundle now requires `doctrine/doctrine-migrations-bundle`. * If you use Ibexa CMS, also require [netgen/remote-media-ibexa](https://github.com/netgen/remote-media-ibexa), which provides the field type, the admin UI integration and the rich text integration that were removed from this bundle. * PHP 8.1+, Symfony 5.4 or 6.2+ (Symfony 7 is not supported), `doctrine/orm` 2.10+, `doctrine/doctrine-bundle` 2.4+ and `cloudinary/cloudinary_php` 2.9+ are required. * `netgen/open-graph-bundle` is no longer supported and the Open Graph handler is removed. @@ -37,7 +18,19 @@ Version 3.0 is a major release. The bundle is decoupled from eZ / Ibexa and cont * The `ngremotemedia_field_link` table is no longer used. * The bundle maps two new entities to the `ngrm_remote_resource` and `ngrm_remote_resource_location` tables with Doctrine XML mappings. -* This bundle does not ship Doctrine migrations, create the tables with the schema tooling of your project (for example a migration generated with `doctrine:migrations:diff`). +* The tables are created by the Doctrine migration shipped with the bundle (own configuration `migrations/doctrine.yaml`, version table `ngrm_migration_versions`). Run it with: + + ``` + php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml + ``` + +* If the tables already exist (for example, created with `doctrine:schema:update` on an untagged 3.0), the migration fails. Create the version table, mark the migration as executed and run the migrations again: + + ``` + php bin/console doctrine:migrations:sync-metadata-storage --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml + php bin/console doctrine:migrations:version 'Netgen\RemoteMedia\Migrations\Doctrine\Version030000' --add --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml + php bin/console doctrine:migrations:migrate --configuration=vendor/netgen/remote-media-bundle/migrations/doctrine.yaml + ``` * Data migration from the v2 data to the new tables is not part of this bundle yet, v2 data is not migrated automatically. ### Configuration