Bonjour,
je suis actuellement un cours laravel et je rencontre une erreur quant j'essaye de reproduire un exemple.
j'ai deux class dans le dossier migration qui sont ainsi
pour la tables companies
et pour la table addresses
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCompaniesTable extends Migration { /** * Run the migrations. * * @return void * */ public function up() { Schema::create('companies', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned; $table->string('name')->index(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('companies'); } }
quant j’exécute la commande php artisan migrate j'ai ce message d'erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateAddressesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('addresses', function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id')->unsigned; $table->string('address')->index(); $table->string('city')->index(); $table->string('zipcode')->index(); $table->string('country')->index(); $table->integer('company_id')->unsigned; $table->foreign('company_id') ->references('id') ->on('companies'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('addresses'); } }
mes tables sont en innodb et les colonnes en relation me semble du même type et même caractéristique.1 PDOException::("SQLSTATE[HY000]: General error: 1215 Impossible d'ajouter des contraintes d'index externe")
D:\wamp64\www\monsite\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
2 PDOStatement::execute()
D:\wamp64\www\monsite\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
merci pour l'aide
Partager