Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: MySQL VIEW causes db/convert-charset command to fail #15598

Closed
cweiper opened this issue Aug 26, 2024 · 2 comments
Closed

[5.x]: MySQL VIEW causes db/convert-charset command to fail #15598

cweiper opened this issue Aug 26, 2024 · 2 comments
Labels

Comments

@cweiper
Copy link

cweiper commented Aug 26, 2024

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

  1. Create site on Craft CMS 4
  2. Create custom plugin that creates a simple MySQL view inside a migration
  3. Upgrade to Craft CMS 5
  4. Remove the CRAFT_DB_CHARSET and CRAFT_DB_COLLATION settings
  5. 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",
@angrybrad
Copy link
Member

Thanks for the report - I've created a PR for this here: #15600

@brandonkelly
Copy link
Member

Craft 4.12.0 and 5.4.0 are out with that fix. Thanks again!

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

No branches or pull requests

5 participants
@brandonkelly @angrybrad @cweiper and others