HEX
Server: Apache
System: Linux server1.ariadata.co 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: nepi (1051)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,show_source,popen,proc_open
Upload Files
File: /home/nepi/www/migrations/upgrades/20191216134009_add_user_last_password_update.php
<?php


use Phinx\Migration\AbstractMigration;

class AddUserLastPasswordUpdate extends AbstractMigration
{
    public function change()
    {
        $usersTable = $this->table('directus_users');
        $fieldsTable = $this->table('directus_fields');

        // -------------------------------------------------------------------------
        // Add password_reset_token column to directus_users
        // -------------------------------------------------------------------------
        if ($usersTable->hasColumn('password_reset_token') == false) {
            $usersTable->addColumn('password_reset_token', 'string', [
                'limit' => 520,
                'encoding' => 'utf8',
                'null' => true,
                'default' => null
            ]);
            $usersTable->save();
        }

        if (!$this->checkFieldExist('directus_users', 'password_reset_token')) {
            $fieldsTable->insert([
                'collection' => 'directus_users',
                'field' => 'password_reset_token',
                'type' =>  \Directus\Database\Schema\DataTypes::TYPE_STRING,
                'interface' => 'text-input',
                'locked' => 1,
                'readonly' => 1,
                'hidden_detail' => 1
            ])->save();
        }
    }

    public function checkFieldExist($collection, $field)
    {
        $checkSql = sprintf('SELECT 1 FROM `directus_fields` WHERE `collection` = "%s" AND `field` = "%s";', $collection, $field);
        return $this->query($checkSql)->fetch();
    }
}