0

I've run the command php bin/magento setup:db-declaration:generate-whitelist --module-name={Vendor_Module}

and receive the following error...

Magento was installed with a table prefix. Please re-install without prefix.

My table names do have a prefix name. What is the best way I can add this prefix for my commands?

I have 2 installations of Magento on the server.

Magento version 2.3.5

3 Answers 3

0

According to Magento docs,

Whitelists cannot be generated on Magento instances that use a database prefix. The presence of a prefix impacts the names of some DB entities, such as the names of keys, and these names cannot be used in generated whitelists. The whitelist should be generated by the extension developer on a development environment with no prefixes.

The db_schema_whitelist.json file is a temporary solution while Magento team is migrating from old setup scripts to the declarative schema. It will be removed in the future, when upgrade scripts are no longer supported. It is used just to keep a track of the database updates.

Refer below link

https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/migration-commands.html#create-whitelist

0

This is expected behavior. The whitelist should be generated on dev environment by the extension developer, so it should not be necessary to support DB with prefix.

Presence of the prefix impacts names of DB entities (such as names of keys), and such names can't be used in the generated whitelist.

The whitelist is a temporary solution while we're migrating from old setup scripts to the declarative schema, and in the future will be eliminated (together with the whitelist command).

Please refer this link

0

This error suggests that a table prefix was used during the installation of Magento. In my case, I used table_prefix as m_. To fix it, I've done the following steps:

  1. Backup Magento database,

  2. Modify the app/etc/env.php file: From 'table_prefix' => 'm_' To 'table_prefix' => ''

  3. Create a SQL script to rename tables. The following query will generate the RENAME script:

    SELECT CONCAT('RENAME TABLE ', CONCAT(table_name, CONCAT(' TO ', CONCAT(substr(TABLE_NAME, 3), ';')))) FROM information_schema.tables WHERE TABLE_SCHEMA = 'DB_NAME';

Use your database name instead of DB_NAME. inventory_stock_1 was needed to modify to remove DB_prefix. Also, sequence_table column's data of sales_sequence_meta is needed to modify.

  1. Run the SQL script to rename all tables.

  2. Clear Magento cache and run the followig:

    php -f bin/magento setup:upgrade rm -rf var/di generated/* php -f bin/magento setup:di:compile

    rm -rf pub/static//; rm -rf var//; php -f bin/magento setup:static-content:deploy -f php -f bin/magento cache:flush

  3. Finally, Generate whitelist by running the following command:

    php -f bin/magento setup:db-declaration:generate-whitelist --module-name={Vendor_Module}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.