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

Something went wrong: SQLSTATE[HY000] - MySQL: 5.7.23 #1675

Closed
terabytesoftw opened this issue Dec 2, 2018 · 12 comments
Closed

Something went wrong: SQLSTATE[HY000] - MySQL: 5.7.23 #1675

terabytesoftw opened this issue Dec 2, 2018 · 12 comments

Comments

@terabytesoftw
Copy link

terabytesoftw commented Dec 2, 2018

hi, installed flarum branch dev-master,

Something went wrong: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table tag_useradd constrainttag_user_tag_id_foreign foreign key (tag_id) references tags (id) on delete cascade)

The problem tables:

  • migrations. --> MyIsam.
  • tags --> MyIsam.

The rest od tables if you create in Innodb.

Environment

  • Flarum version: dev-master
  • Webserver: LiteSpeedTech
  • Hosting environment: Shared.
  • PHP version: 7.1
@tobyzerner
Copy link
Contributor

tobyzerner commented Dec 2, 2018

@franzliedke can you please look at this in relation to fb6b51b?

@terabytesoftw
Copy link
Author

@tobscure its correct but tags is a separate extension and creates the tables as MyISAM, I proble flarum / core as dev-master and it did not work just those two tables (tags, migrations) all the others are like innodb.

@tobyzerner
Copy link
Contributor

The changes in fb6b51b should theoretically force InnoDB to be used for all tables, including those created by extensions, and the migrations table.

Are you experiencing this on a totally fresh install of dev-master?

@terabytesoftw
Copy link
Author

terabytesoftw commented Dec 2, 2018

If a completely new installation of zero, is correct using flarum/core dev-master

@bobbwal
Copy link

bobbwal commented Dec 3, 2018

I'm having the same issues on a fresh install. Even with the changes from fb6b51b my migrations and tags are created as MyISAM.

@tobyzerner tobyzerner added this to the 0.1.0-beta.8.1 milestone Dec 3, 2018
franzliedke added a commit to flarum/tags that referenced this issue Dec 4, 2018
@franzliedke
Copy link
Contributor

Ah, I'd figured it would be something like this. However, fb6b51b also sets InnoDB as engine for every table created through Migration::createTable. It turns out that the tags table is the only one not using that helper, which is why the default was necessary. That said, I just added an explicit InnoDB engine to that table's migration.

@franzliedke
Copy link
Contributor

I guess we could also add the explicit schema to the migrations repository: https://github.com/flarum/core/blob/796b57753d34d4ea741dbebcbc550b17808f6c94/src/Database/DatabaseMigrationRepository.php#L102-L105

@tobscure @luceos What do you think?

@tobyzerner
Copy link
Contributor

tobyzerner commented Dec 4, 2018

@franzliedke If we have properly set the default engine in the config then we shouldn't need to define it explicitly in the schema at all. Remember by adding the "InnoDB" line to our migrations we are automatically making them MySQL-only.

@luceos
Copy link
Member

luceos commented Dec 5, 2018

I agree with @tobscure ; adding enforcement in different locations might only complicate trouble shooting in the future.

franzliedke added a commit that referenced this issue Dec 5, 2018
As argued in #1675, this makes us slightly less reliant on MySQL.
@franzliedke
Copy link
Contributor

I agree with the reasoning about being MySQL-specific, and I have reverted all changes that set InnoDB explicitly for table creation statements.

That said, there is at least one existing migration where we explicitly set the engine, and some code (e.g. fulltext search) is very MySQL-specific, so I am not entirely sure that we will ever be able to seamlessly enable other DB engines.

@marcteys
Copy link

I guess it's related, but when I try to run php flarum migrate I also end up with this error:

In Connection.php line 664:
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `flar_posts` add constraint `flar_posts_user_id_foreign` foreign key (`user_id`) references `flar_users` (`id`) on delete set null)

I guess the issue is not solved ?
I am also running on mysql. From your comments, you suggest that I should switch to innoDB for the migration?

@luceos
Copy link
Member

luceos commented Jan 18, 2019

@marcteys Marc please create a new issue and add the information we ask you there, amongst others the php flarum info output. Thank you.

wzdiyb pushed a commit to wzdiyb/core that referenced this issue Feb 16, 2020
The installer doesn't use DatabaseServiceProvider, so we need to set
the default engine in the config here too.

Fixes flarum#1675
wzdiyb pushed a commit to wzdiyb/core that referenced this issue Feb 16, 2020
As argued in flarum#1675, this makes us slightly less reliant on MySQL.
askvortsov1 pushed a commit to flarum/tags that referenced this issue Mar 11, 2022
askvortsov1 pushed a commit to flarum/tags that referenced this issue May 10, 2022
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

6 participants