I have this code for migration
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAvatarsTable extends Migration
{
public function up()
{
Schema::create('avatars', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 100)->nullable();
$table->string('filename', 255)->nullable();
$table->text('detail')->nullable();
$table->text('pos_x')->nullable();
$table->text('pos_y')->nullable();
$table->integer('avatars_id')->nullable();
$table->foreign('avatars_id')->references('id')->on('avatars')->onUpdate('cascade')->onDelete('cascade');
$table->softDeletes();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('avatars');
}
}
When I run the code for generate migrations
php artisan migrate:refresh
I got this result:
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: alter table
avatars
add con straintavatars_avatars_id_foreign
foreign key (avatars_id
) references `` (id
) on delete cascade)[Doctrine\DBAL\Driver\PDOException] SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''