for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
class CreateUserSocialTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
Schema::create('user_socials', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('provider');
$table->string('social_id')->index();
$table->string('email')->index()->nullable();
$table->string('avatar')->nullable();
$table->string('token');
$table->string('refresh_token')->nullable();
$table->integer('expires_in')->nullable();
$table->timestamps();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
DB::statement('ALTER TABLE `users` MODIFY `password` VARCHAR(64);');
}
* Reverse the migrations.
public function down()
Schema::drop('user_socials');
if (DB::table('users')->count() === 0) {
DB::statement('ALTER TABLE `users` MODIFY `password` VARCHAR(64) NOT NULL;');