Matomo_custom_dimensions table missing after Matomo 4 upgrade

TLDR; what’s the SQL statement which Matomo 4 uses to create the “matomo_custom_dimensions” table?

Windows command prompt crashed while upgrading Matomo 3.14.1 to 4.4.1 via “console core:update”.

Running “console core:update” again successfully completed the upgrade, but I now have a missing table for the “CustomDimensions” plugin which causes the following error in the Web UI:

An exception has been thrown during the rendering of a template (“SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘matomo4.matomo_custom_dimensions’ doesn’t exist”).
in D:\Websites\matomo4\plugins\CoreHome\templates\getDefaultIndexView.twig line 7

I have deactivated the “CustomDimensions” plugin in the meantime. Re-activating it does not create the table, so I need to obtain the SQL command needed to do so.

Thanks,
David

I resolved this by installing an instance of Matomo 4 locally, dumping the “matomo_custom_dimensions” table and using the dump’s CREATE TABLE command to recreate the missing table on the upgraded instance of Matomo.

In case it helps anyone who experiences the same issue, the SQL in question is as follows:

CREATE TABLE `matomo_custom_dimensions` (
  `idcustomdimension` bigint(20) unsigned NOT NULL,
  `idsite` bigint(20) unsigned NOT NULL,
  `name` varchar(100) NOT NULL,
  `index` smallint(5) unsigned NOT NULL,
  `scope` varchar(10) NOT NULL,
  `active` tinyint(3) unsigned NOT NULL DEFAULT 0,
  `extractions` text NOT NULL DEFAULT '',
  `case_sensitive` tinyint(3) unsigned NOT NULL DEFAULT 1,
  PRIMARY KEY (`idcustomdimension`,`idsite`),
  UNIQUE KEY `uniq_hash` (`idsite`,`scope`,`index`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

I was then able to re-activate the “CustomDimensions” plugin without any errors being generated.

1 Like