What happened?
Description
After updating our site with a custom plugin to Craft 5, running php craft db/convert-charset fails with the following error:
Converting view_name_here ... Error: SQLSTATE[HY000]: General error: 1347 'db.view_name_here' is not BASE TABLE
We are using a view to aggregate votes from a submissions table
Steps to reproduce
- Create site on Craft CMS 4
- Create custom plugin that creates a simple MySQL view inside a migration
- Upgrade to Craft CMS 5
- Remove the CRAFT_DB_CHARSET and CRAFT_DB_COLLATION settings
- Run
php craft db/convert-charset
Example view creation code
// Create a view that shows the number of votes for each flavor and order by the number of votes
$this->execute('CREATE VIEW votes_by_choice AS
SELECT choiceId, SUM(numberOfVotes) AS numberOfVotes
FROM votes_submissions
GROUP BY choiceId
ORDER BY numberOfVotes DESC');
Expected behavior
Charset should be converted successfully
Actual behavior
Command fails with an error
Craft CMS version
5.3.6
PHP version
8.2
Operating system and version
DDEV
Database type and version
MySQL 8.0
Image driver and version
No response
Installed plugins and versions
- Custom Voting Plugin
"craftcms/ckeditor": "4.0.6",
"craftcms/cms": "^5.0.0",
"craftcms/shopify": "5.1.1",
"nystudio107/craft-retour": "5.0.0",
"nystudio107/craft-seomatic": "5.0.3",
"putyourlightson/craft-blitz": "5.3.1",
"verbb/formie": "3.0.3",
What happened?
Description
After updating our site with a custom plugin to Craft 5, running
php craft db/convert-charsetfails with the following error:Converting view_name_here ... Error: SQLSTATE[HY000]: General error: 1347 'db.view_name_here' is not BASE TABLEWe are using a view to aggregate votes from a submissions table
Steps to reproduce
php craft db/convert-charsetExample view creation code
// Create a view that shows the number of votes for each flavor and order by the number of votes
$this->execute('CREATE VIEW votes_by_choice AS
SELECT choiceId, SUM(numberOfVotes) AS numberOfVotes
FROM votes_submissions
GROUP BY choiceId
ORDER BY numberOfVotes DESC');
Expected behavior
Charset should be converted successfully
Actual behavior
Command fails with an error
Craft CMS version
5.3.6
PHP version
8.2
Operating system and version
DDEV
Database type and version
MySQL 8.0
Image driver and version
No response
Installed plugins and versions
"craftcms/ckeditor": "4.0.6",
"craftcms/cms": "^5.0.0",
"craftcms/shopify": "5.1.1",
"nystudio107/craft-retour": "5.0.0",
"nystudio107/craft-seomatic": "5.0.3",
"putyourlightson/craft-blitz": "5.3.1",
"verbb/formie": "3.0.3",