M
M
matros972018-12-27 13:04:40
Laravel
matros97, 2018-12-27 13:04:40

Error creating migration?

Hello, I am creating a migration for posts
, here is the code

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();

            $table->string('title');
            $table->string('images')->nullable();
            $table->string('slug')->unique();
            $table->text('description')->nullable();
            $table->text('text');
            $table->date('date')->nullable();
            $table->boolean('view')->default(1);
            $table->integer('category_id')->nullable();
            $table->foreign('category_id')->references('id')->on('сategories');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('posts');
    }
}

and here is the error
5c24a3b0ba768457120411.png
that I did not do it right

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasyl Fomin, 2018-12-27
@fomvasss

Or remove in this migration
$table->foreign('category_id')->references('id')->on('categories');
Or before this migration, make a migration that will create the categories table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question