Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tghelere/fd2fa49ff7d636fa5191414bdc6e4b8b to your computer and use it in GitHub Desktop.
Save tghelere/fd2fa49ff7d636fa5191414bdc6e4b8b to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoryPostTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('category_post', function (Blueprint $table) {
$table->increments('id');
$table->integer('category_id')->unsigned();
$table->integer('post_id')->unsigned();
$table->foreign('category_id')->references('id')->on('categories');
$table->foreign('post_id')->references('id')->on('posts');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('category_post');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment