Shopware 6: Can't migrate database
Asked Answered
D

3

7

I've followed the following tutorial for creating a custom entity on my own in shopware 6:

https://www.youtube.com/watch?v=mTHTyof4gPk

I created a migration by using

bin/console database:create-migration

and added the following code:

$sql = <<<SQL
CREATE TABLE IF NOT EXISTS  'applicationmanagement' (
    'id' BINARY(26) NOT NULL,
    'name' VARCHAR (255) COLLATE utf8mb4_unicode_ci,
    'created_at' DATETIME(3) NOT NULL,
    'update_at' DATETIME(3),
    PRIMARY KEY ('id')
)
    ENGINE = InnoDB
    DEFAULT CHARSET = utf8mb4
    COLLATE = utf8mb4_unicaode_ci;
SQL;

$connection->executeUpdate($sql);

When I try to execute the migration by using

bin/console database:migrate PluginName --all

I get the following note

Get collection for identifier: "PluginName"

 ! [NOTE] No collection found for identifier: "PluginName", continuing   

I tried reinstall and refresh the plugin but it didn't do anything.

Can someone help me fix this problem?

Dabster answered 17/2, 2022 at 15:13 Comment(1)
You can Xdebug into \Shopware\Core\Framework\Migration\MigrationCollectionLoader::collect and check the variable $this->migrationSources for which names are available here.Recite
G
11

I just had the same problem. What helped me was to clear the cache

bin/console cache:clear
Game answered 31/3, 2022 at 8:41 Comment(0)
D
5

I solved it by uninstalling the plugin, refreshing the plugins and after that installing and activating my plugin

Dabster answered 18/2, 2022 at 8:45 Comment(2)
I guess Shopware did not detect the change, if you did not update the version number. If you did, it would have prompted your to upgrade.Recite
thx - had the same issue. Followed the steps from our solution approach and everything worked fine.Selfjustifying
M
0

There is probably a wrong command creating migration because you didn't add Plugin name so your migration was created in shopware core - look at this Creating migration... Creating legacy core migration ... Migration created: "/app/shopware/dev/platform/src/Core/Migration/Migration1674222844.php" Creating core-migration ... Migration created: "/app/shopware/dev/platform/src/Core/Migration/V6_4/Migration1674222844.php" Look at documentation how to create migration for plugin: https://developer.shopware.com/docs/guides/plugins/plugins/plugin-fundamentals/database-migrations command- $ ./bin/console database:create-migration -p SwagBasicExample --name ExampleDescription

Mouldy answered 20/1, 2023 at 13:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.