Laravel Example of Migration and Table declaration

 

 

<?php

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

class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
schema::create(‘users’, function (blueprint $table) {
$table->increments(‘user_id’);
$table->string(‘username’,30)->unique();
$table->string(’email’,50)->unique();
$table->string(‘password’); /* hashed */
$table->char(‘status’, 1);
$table->remembertoken();
$table->timestamp(‘created_at’);
$table->timestamp(‘updated_at’);
});
}

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

Leave a Reply

Your email address will not be published. Required fields are marked *