Witam. Przy próbie wykonania migracji w frameworku Laravel (wersja 6.0.3) i bazie danych MySQL (serwis remotemysql.com) wywala mi błąd:
Migrating: 2019_11_22_094321_add_foreign_keys
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') default character set utf8mb4 collate 'utf8mb4_unicode_ci'' at line 1 (SQL: create table `parts` () default character set utf8mb4 collate 'utf8mb4_unicode_ci')
at /home/kamils/php/collection/vendor/laravel/framework/src/Illuminate/Database/Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {
> 665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') default character set utf8mb4 collate 'utf8mb4_unicode_ci'' at line 1")
/home/kamils/php/collection/vendor/laravel/framework/src/Illuminate/Database/Connection.php:453
2 PDO::prepare("create table `parts` () default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
/home/kamils/php/collection/vendor/laravel/framework/src/Illuminate/Database/Connection.php:453
Please use the argument -v to see more details.
A tu migracja, która wywołuje ten błąd:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddForeignKeys extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('parts', function (Blueprint $table) {
$table->foreign('owner')->references('id')->on('users')->change();
});
Schema::create('sets', function (Blueprint $table) {
$table->foreign('owner')->references('id')->on('users')->change();
});
Schema::create('images', function (Blueprint $table) {
$table->foreign('partId')->references('id')->on('parts')->change();
$table->foreign('setId')->references('id')->on('sets')->change();
});
Schema::table('features', function (Blueprint $table){
$table->foreign('featureType')->references('id')->on('feature_types')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
Proszę o pomoc, googlowanie i samodzielne próby tylko pogarszały sprawę :/