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

Migration Incomplete, SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint ... #1730

Closed
marcteys opened this issue Jan 18, 2019 · 6 comments
Labels

Comments

@marcteys
Copy link

When doing a migration from flarum beta, 7.1 the migration stop at some point and returns the error below.
This happens after the command php flarum migrate.

I don't have any ideas on how to solve this issue. If I remove the file 2018_01_18_135100_change_posts_add_foreign_keys.php from core/migrations (and others problematics files, it's kinda working but the migration is not fully performed (some bugs are present in the forum, I can see the posts but can't login).

I have the feeling that it might come from ->onDelete('set null'); but I can't dig more. It might be related to this issue.
Do you have any ideas on how to solve it?

... 
Migrated: 2018_01_18_135000_change_posts_rename_columns

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)
In PDOStatement.php line 119:
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
In PDOStatement.php line 117:
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
migrate

Environment

  • Flarum version: 0.1.0-beta.8.1
  • Webserver: apache
  • Hosting environment: localhost
  • PHP version: 7.1.26
  • Database: MySQL 5.7.24
Loaded extensions: Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, mcrypt, SPL, pcre, readline, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, xml, wddx, xmlreader, xmlwriter, openssl, curl, fileinfo, gd, gettext, gmp, intl, imap, ldap, mbstring, exif, mysqli, Phar, pdo_mysql, pdo_sqlite, soap, sockets, sqlite3, xmlrpc, xsl
+-------------------+---------+--------+
| Flarum Extensions |         |        |
+-------------------+---------+--------+
| ID                | Version | Commit |
+-------------------+---------+--------+
Base URL: http://localhost/forum
Installation path: C:\wamp64\www\forum
Debug mode: off
@marcteys marcteys changed the title Migration Incomplete, Error 1215 Migration Incomplete, SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint ... Jan 18, 2019
@MichaelBelgium
Copy link

Flarum Extensions

There's none? Not even the core extensions are installed?

@marcteys
Copy link
Author

That's the output I have. I disabled all of them before the migration

@luceos
Copy link
Member

luceos commented Jan 21, 2019

@marcteys what is the output of mysql -v?

@marcteys
Copy link
Author

Here is my output for mysql version:

+-------------------------+------------------------------+
| Variable_name           | Value                        |
+-------------------------+------------------------------+
| innodb_version          | 5.7.24                       |
| protocol_version        | 10                           |
| slave_type_conversions  |                              |
| tls_version             | TLSv1,TLSv1.1                |
| version                 | 5.7.24                       |
| version_comment         | MySQL Community Server (GPL) |
| version_compile_machine | x86_64                       |
| version_compile_os      | Win64                        |
+-------------------------+------------------------------+

@franzliedke
Copy link
Contributor

@marcteys Do you still have the database at the exact state of when the installer broke down? Or can you easily reproduce this? If so, please check the possible reasons mentioned in this StackOverflow answer.

@tobyzerner
Copy link
Contributor

Closing as stale

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