62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateRememberTokensTable extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
'auto_increment' => true,
|
|
],
|
|
'user_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
'selector' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 64,
|
|
],
|
|
'token_hash' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 128,
|
|
],
|
|
'expires_at' => [
|
|
'type' => 'DATETIME',
|
|
],
|
|
'created_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
'user_agent' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 500,
|
|
'null' => true,
|
|
],
|
|
'ip_address' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 45,
|
|
'null' => true,
|
|
],
|
|
]);
|
|
$this->forge->addKey('id', true);
|
|
$this->forge->addKey('user_id');
|
|
$this->forge->addKey('selector');
|
|
$this->forge->addKey('expires_at');
|
|
$this->forge->addForeignKey('user_id', 'users', 'id', false, 'CASCADE');
|
|
$this->forge->createTable('remember_tokens');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('remember_tokens');
|
|
}
|
|
}
|