Skip to content

Instantly share code, notes, and snippets.

@Acen
Created January 25, 2018 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Acen/b3375b5513a068189a0255d80e9ea26e to your computer and use it in GitHub Desktop.
Save Acen/b3375b5513a068189a0255d80e9ea26e to your computer and use it in GitHub Desktop.
Migration things
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tokens', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('jwt');
$table->boolean('active')->default(true);
$table->timestamp('expires_at');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tokens');
}
}
<?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('id');
$table->string('user');
$table->string('password');
$table->unsignedInteger('token_id');
$table->timestamps();
$table->softDeletes();
$table->foreign('token_id')->references('id')->on('tokens');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment