mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
DbMigration: Check for mysql collation name whether to check 2.11 is migrated
This commit is contained in:
parent
3f372330b3
commit
2505e79a2d
@ -107,6 +107,35 @@ abstract class DbMigrationHook implements Countable
|
|||||||
return $result->column_type;
|
return $result->column_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mysql collation name of the given column of the specified table
|
||||||
|
*
|
||||||
|
* @param Connection $conn
|
||||||
|
* @param string $table
|
||||||
|
* @param string $column
|
||||||
|
*
|
||||||
|
* @return ?string
|
||||||
|
*/
|
||||||
|
public static function getColumnCollation(Connection $conn, string $table, string $column): ?string
|
||||||
|
{
|
||||||
|
if ($conn->getAdapter() instanceof Pgsql) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdoStmt = $conn->prepexec(
|
||||||
|
'SELECT collation_name FROM information_schema.columns WHERE table_name = ? AND column_name = ?',
|
||||||
|
[$table, $column]
|
||||||
|
);
|
||||||
|
|
||||||
|
/** @var false|stdClass $result */
|
||||||
|
$result = $pdoStmt->fetch(PDO::FETCH_OBJ);
|
||||||
|
if ($result === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result->collation_name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get statically provided descriptions of the individual migrate scripts
|
* Get statically provided descriptions of the individual migrate scripts
|
||||||
*
|
*
|
||||||
|
@ -52,7 +52,9 @@ class DbMigration extends DbMigrationHook
|
|||||||
if (! $this->version) {
|
if (! $this->version) {
|
||||||
$this->version = '2.12.0';
|
$this->version = '2.12.0';
|
||||||
}
|
}
|
||||||
} elseif (static::tableExists($conn, $schemaQuery->getModel()->getTableName())) {
|
} elseif (static::tableExists($conn, $schemaQuery->getModel()->getTableName())
|
||||||
|
|| static::getColumnCollation($conn, 'icingaweb_user_preference', 'username') === 'utf8mb4_unicode_ci'
|
||||||
|
) {
|
||||||
$this->version = '2.11.0';
|
$this->version = '2.11.0';
|
||||||
} elseif (static::tableExists($conn, 'icingaweb_rememberme')) {
|
} elseif (static::tableExists($conn, 'icingaweb_rememberme')) {
|
||||||
$randomIvType = static::getColumnType($conn, 'icingaweb_rememberme', 'random_iv');
|
$randomIvType = static::getColumnType($conn, 'icingaweb_rememberme', 'random_iv');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user