base-laravel/database/migrations/2014_10_12_000000_create_users_table.php

50 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2020-07-27 16:17:36 -05:00
<?php
use Illuminate\Support\Facades\Schema;
2020-07-27 19:15:58 -05:00
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
2020-07-27 16:17:36 -05:00
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
2020-07-27 19:15:58 -05:00
$table->increments('id');
2020-07-27 16:17:36 -05:00
$table->string('name');
2020-07-27 19:15:58 -05:00
$table->string('email');
2020-07-27 16:17:36 -05:00
$table->string('password');
$table->rememberToken();
$table->timestamps();
2020-07-27 19:15:58 -05:00
if(env('DB_CONNECTION') == 'mysql'){
$table->unique([DB::raw('email(191)')]);
}else{
$table->unique('email');
}
2020-07-27 16:17:36 -05:00
});
2020-07-27 19:15:58 -05:00
//Insert default admin
DB::table('users')->insert([
'name' => 'Admin',
'email' => 'admin@example.com',
'password' => bcrypt('temp'),
'created_at' => NOW()
]);
2020-07-27 16:17:36 -05:00
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}