osb/spark/install-stubs/database/migrations/create_api_tokens_table.php

40 lines
955 B
PHP
Raw Normal View History

2017-11-03 05:26:07 +00:00
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateApiTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('api_tokens', function (Blueprint $table) {
$table->string('id')->primary();
$table->integer('user_id');
$table->string('name');
$table->string('token', 100)->unique();
$table->text('metadata');
$table->tinyInteger('transient')->default(0);
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'expires_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('api_tokens');
}
}