jjdejong/phpip

2020_02_22_183512_add_foreignkeys_to_template_classes

Closed this issue · 4 comments

Bonjour,
j'espère que vous allez bien.
après quelques temps j'ai voulu me mettre à jour, et j'ai l'erreur suivante.
Je suis donc bloqué et je ne sais pas ce qu'il faut faire.
Alexandre

Migrated: 2020_02_22_161215_create_template_classes (0.34 seconds)
Migrating: 2020_02_22_164446_create_template_members
Migrated: 2020_02_22_164446_create_template_members (0.62 seconds)
Migrating: 2020_02_22_173742_create_event_class_lnk
Migrated: 2020_02_22_173742_create_event_class_lnk (0.2 seconds)
Migrating: 2020_02_22_181558_add_foreignkeys_to_template_members
Migrated: 2020_02_22_181558_add_foreignkeys_to_template_members (1.14 seconds)
Migrating: 2020_02_22_183512_add_foreignkeys_to_template_classes

Illuminate\Database\QueryException

SQLSTATE[HY000]: General error: 1005 Can't create table phpip.template_classes (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table template_classes add constraint template_classes_default_role_foreign foreign key (default_role) references actor_role (code) on delete SET NULL on update CASCADE)

at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {

671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|

  +11 vendor frames 

12 database/migrations/2020_02_22_183512_add_foreignkeys_to_template_classes.php:18
Illuminate\Support\Facades\Facade::__callStatic("table")

  +22 vendor frames 

35 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Bonjour,
Il faudrait vérifier l'interclassement des champs, respectivement de code dans la table actor_role et default_role dans la table template_classes. Il doit être le même. Chez moi, j'ai utf8mb4_unicode_ci.

La commande
SHOW CREATE DATABASE phpip
renvoie la valeur de jeu de caractères et d'interclassement par défaut.
CREATE DATABASE phpip /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */

Merci