Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cwx4f7otbzlmf7ap.piwik_option' doesn't exist #2

Open
elalemanyo opened this issue Sep 24, 2018 · 10 comments

Comments

@elalemanyo
Copy link

Hi,
I am trying to deploy piwik/matomo on Heroku. Deploy runs without problem, but when I call the url I just see this error:
Original error was "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cwx4f7otbzlmf7ap.piwik_option' doesn't exist".

Any idea what is going wrong?

Thanks!

@creativecoder
Copy link
Owner

Haven't seen that error before, but a few things I'd recommend checking:

  1. Is there a mysql database connected to your Heroku app?
  2. If so, are the database credentials in the config for your app?
  3. Do the config variable names match those listed in config.ini.php?

From the error, it seems like the tables_prefix setting might need to be changed.

@elalemanyo
Copy link
Author

Ok, I check all the stuff you told me and I didn't find any error.

  1. Database is connected to my Heroku App
  2. Config Vars are there:
    2018-09-26_1105
  3. I am using the same variables names as you.
  4. I change tables_prefix and I get same erro...

I connect to my dyno and the tree looks strange, there is not config directory

2018-09-26_1107

I am sure I am missing something, but not sure what.

Thanks for your help

@elalemanyo
Copy link
Author

I remove the config file going inside the dyno and than installation runs... is that the normal way to do it? How is the best way to update Matomo after that? Using the composer.json?

Thanks

@creativecoder
Copy link
Owner

Glad you got it working!

I remove the config file going inside the dyno and than installation runs...

What exactly does this mean? You're deleting config.ini.php after deploying? Or deleting vendor/piwik/piwik/config/config.ini.php?

The way a deploy works is

  1. Matomo is installed in vendor/piwik/piwik by composer
  2. Composer runs a post deploy script to copy some things needed into that directory for the software to work (https://github.com/creativecoder/piwik-heroku/blob/master/composer.json#L79), including copying the config.ini.php file in the root of the repo into vendor/piwik/piwik/config/

If you install plugins or other things that write to config.ini.php, you need to manually duplicate those changes and commit them to make them persist. Otherwise they'll be overwritten on the next rebuild/deploy of the app.

To update, you can run composer locally and commit the changes to composer.json, then push to heroku

  • composer update piwik/piwik to get minor version updates
  • composer require piwik/piwik will get the latest version, including major version updates

Note that some of the sub repositories (matomo/matomo-icons and matomo/matomo-log-analytics) are not set up to work with composer, so you have to manually bump the version number in composer.json in the "repositories" section to tell composer to fetch the latest versions of those from github.

At some point everything is going to be renamed, and then the composer.json file in this repo will need to be reworked.

@elalemanyo
Copy link
Author

Hi,
Yes, what I did is remove vendor/piwik/piwik/config/config.ini.php and after that the installation was done. I think the problem was that installation was done, but the tables have not being created... I would try again, maybe was my problem.

No I am trying to fix to issues:

2018-09-27_1001

2018-09-27_1001_2

Any idea?

Thanks for all your help already!

@creativecoder
Copy link
Owner

Yes, what I did is remove vendor/piwik/piwik/config/config.ini.php and after that the installation was done.

Interesting--it's been a while since I did a fresh install. From your experience it seems like database needs to be set up before copying over the config file.

I believe the "File integrity" warning is normal, since installing from composer is similar to a git deployment, as mentioned in the note below that warning.


For GeoIP, if you've successfully added the geoip buildpack to your app, you should be able to select this option from the Geolocation settings to get it working

screen shot 2018-09-28 at 10 11 47

@elalemanyo
Copy link
Author

Ok, thanks for all your help!

@realmhamdy
Copy link

realmhamdy commented Oct 20, 2018

I'm getting the same error. Here's a screenshot:
matomo-error

I don't know how the OP resolved the problem. I tried deleting vendor/piwik/piwik/config/config.ini.php then refreshing the page but that didn't change the outcome.

Update: I also tried changing the tables_prefix setting and that didn't work either.

@realmhamdy
Copy link

realmhamdy commented Oct 26, 2018

For those who are stuck with this database error: the trick is to remove config.ini.php (like the OP suggested) but removing it directly using the rm command on the heroku instance is not going to work. You can disable copying that file as part of the build by removing && cp config.ini.php vendor/piwik/piwik/config/ from the post-install-cmd in composer.json. Then commit and push to heroku.

@creativecoder
Copy link
Owner

@github-account-because-they-want-it Thanks for following up with a workaround for this issue. Looks like we need a way to detect if the database exists or not and then copy config file only after the database has been created.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants