40 lines
955 B
PHP
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');
|
|
}
|
|
}
|