30 lines
871 B
PHP
30 lines
871 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class AddTokenExpiresToUsers extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
// Проверяем, существует ли уже поле token_expires_at
|
|
$fields = $this->db->getFieldData('users');
|
|
$existingFields = array_column($fields, 'name');
|
|
|
|
if (!in_array('token_expires_at', $existingFields)) {
|
|
$this->db->simpleQuery("ALTER TABLE users ADD COLUMN token_expires_at DATETIME NULL AFTER verification_token");
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$fields = $this->db->getFieldData('users');
|
|
$existingFields = array_column($fields, 'name');
|
|
|
|
if (in_array('token_expires_at', $existingFields)) {
|
|
$this->db->simpleQuery("ALTER TABLE users DROP COLUMN token_expires_at");
|
|
}
|
|
}
|
|
}
|