domovoy/db/migrations/20250526000007_create_crede...

30 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreateCredentials extends AbstractMigration
{
public function change(): void
{
$table = $this->table('credentials');
$table
->addColumn('device_id', 'integer', ['null' => false])
->addColumn('type', 'string', ['limit' => 30, 'null' => false, 'default' => 'ssh'])
->addColumn('name', 'string', ['limit' => 255, 'null' => false])
->addColumn('username', 'string', ['limit' => 255, 'null' => false])
->addColumn('port', 'integer', ['null' => false, 'default' => 22])
->addColumn('auth_method', 'string', ['limit' => 30, 'null' => false, 'default' => 'password'])
->addColumn('encrypted_secret', 'text', ['null' => true])
->addColumn('encrypted_private_key', 'text', ['null' => true])
->addColumn('public_key_fingerprint', 'string', ['limit' => 255, 'null' => true])
->addColumn('last_test_status', 'string', ['limit' => 30, 'null' => true])
->addColumn('last_test_at', 'datetime', ['null' => true])
->addColumn('created_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
->addColumn('updated_at', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
->addIndex(['device_id'])
->create();
}
}