Created
June 22, 2015 17:57
-
-
Save malgorath/d407abfa01e8652c3c94 to your computer and use it in GitHub Desktop.
Articles Migration File for Laravel 5.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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