Whenever I try to migrate my database to Laravel I have that problem.
I tried several options but none of them seem to work. Thanks in advance!
Users table:
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('avatar',100)->nullable();
$table->string('country',100)->nullable();
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->unsignedBigInteger('product_id')->unsigned();
$table->foreign('product_id')->references('id')->on('products');
$table->rememberToken();
$table->timestamps();
});
}
Create Products table:
enter code here:
Schema::create('products', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 100);
$table->decimal('price', 8, 2);
$table->string('image', 100);
$table->unsignedBigInteger('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->timestamps();
});
}
Add Category id to Column Products:
enter code here:
Schema::table('products', function (Blueprint $table) {
$table->unsignedBigInteger('category_id')->nullable();
$table->foreign('category_id')->references('id')->on('categories');
});
}
Interest Table:
enter code here:
Schema::create('interests', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name',100)->nullable();
$table->timestamps();
});
}
Brands table:
enter code here:
Schema::create('brands', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->nullable();
$table->timestamps();
});
}
Add Brand id to Products Table:
enter code here:
Schema::table('products', function (Blueprint $table) {
$table->unsignedBigInteger('brand_id')->nullable();
$table->foreign('brand_id')->references('id')->on('brands');
});
}
Create Category Interest:
enter code here:
Schema::table('products', function (Blueprint $table) {
$table->unsignedBigInteger('brand_id')->nullable();
$table->foreign('brand_id')->references('id')->on('brands');
});
}
2 enter code here:
PDOStatement::execute() /Users/Ezequiel/Desktop/dandelion/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GBxaSS
via IFTTT
Aucun commentaire:
Enregistrer un commentaire