0

I tried to install MailChimp extension through Composer, but when running setup:upgrade I received a database error. Assuming that the problem was in the extension, I restored the backup I made just before installing the extension. Out of curiosity I run "php bin/magento setup:upgrade" again and received the same database error! The error I get is:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mg2_mg_catalogrule_product_price_replica' doesn't exist, query was: SHOW CREATE TABLE mg2_mg_catalogrule_product_price_replica

The prefix of my database is 'mg2_' and somewhere something assumes the table name starts with 'mg_' and then glues even my prefix in front of it.

I didn't have this problem after the last extension I installed. How can I find out what and where a wrong table name is assumed?

2 Answers 2

1

The Magento dev docs for Installing and upgrading the database schema shows the code and functions called on php bin/magento setup:upgrade.

However the mailchimp code doesn't seem to reference this, it would have been in mailchimp/mc-magento2/Setup/InstallSchema.php .

catalogrule_product_price_replica is a table associated with indexing, it might be that the crons are still running indexing or indexing. Please be sure you are in maintenance mode php bin/magento maintenance:enable before php bin/magento setup:upgrade. Also please ensure indexing is up to date and running correctly.

1
  • Sorry, I was abroad for a week.... I've found out the problem is not in MailChimp indeed but in the fact I cloned the website a while ago using Installatron. It renamed all my database tables with a different prefix (from "mg_" to "mg2_" and apparently somehow it gets confused. I will check indexing and if something in the database scheme is changed with double prefix. Commented Mar 2, 2020 at 15:05
0

I solved the problem, but it took more work than expected. A while ago I cloned the website using Installatron and apparently it created also a clone of all database tables. Where the original tables had prefix "mg_" the cloned tables got the prefix "mg2_". However, cloning only copied tables, nothing more. Hence to solve the problem I had to:

  • Create all triggers for tables with prefix mg2_
  • Rename all constraints with prefix mg_ to prefix mg2_
  • In table "sales_sequence_meta" change all records referring to tables with prefix mg_ to prefix mg2_
  • Remove all old tables with prefix mg_

And now it all works again. Since I was set on the right track by the comment that the original error message referred to a table related to the indexer I will accept that answer as the solution.

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.