Implemented device code grant

This commit is contained in:
ErickSkrauch
2024-12-08 16:54:45 +01:00
parent c7d192d14e
commit 2cc27d34ad
28 changed files with 665 additions and 171 deletions

View File

@@ -1,6 +1,9 @@
<?php
declare(strict_types=1);
namespace console\db;
use yii\db\Exception;
use yii\db\Migration as YiiMigration;
/**
@@ -18,6 +21,9 @@ class Migration extends YiiMigration {
return $tableOptions;
}
/**
* @param array<string|\yii\db\ColumnSchemaBuilder>|null $columns
*/
public function createTable($table, $columns, $options = null): void {
if ($options === null) {
$options = $this->getTableOptions();
@@ -34,4 +40,21 @@ class Migration extends YiiMigration {
return ' PRIMARY KEY (' . implode(', ', $columns) . ') ';
}
protected function getPrimaryKeyType(string $table, bool $nullable = false): string {
$primaryKeys = $this->db->getTableSchema($table)->primaryKey;
if (count($primaryKeys) === 0) {
throw new Exception("The table \"{$table}\" have no primary keys.");
}
if (count($primaryKeys) > 1) {
throw new Exception("The table \"{$table}\" have more than one primary key.");
}
return $this->getColumnType($table, $primaryKeys[0], $nullable);
}
protected function getColumnType(string $table, string $column, bool $nullable = false): string {
return $this->db->getTableSchema($table)->getColumn($column)->dbType . ($nullable ? '' : ' NOT NULL');
}
}