Skip to content

Instantly share code, notes, and snippets.

@malgorath
Created June 22, 2015 17:57
Show Gist options
  • Save malgorath/d407abfa01e8652c3c94 to your computer and use it in GitHub Desktop.
Save malgorath/d407abfa01e8652c3c94 to your computer and use it in GitHub Desktop.
Articles Migration File for Laravel 5.1
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateArticlesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->string('title', 255);
$table->string('tag', 255)->unique();
$table->text('description');
$table->text('content');
$table->boolean('active')->default(false);
$table->integer('user_id')->unsigned();
$table->timestamps();
$table->foreign('user_id')->references('id')
->on('users')
->onDelete('restrict')
->onUpdate('restrict');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('articles');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment