This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
site-base/spark/install-stubs/database/migrations/create_api_tokens_table.php
2017-11-03 16:26:07 +11:00

40 lines
955 B
PHP

<?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');
}
}