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