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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -52,7 +52,9 @@ class DbMigration extends DbMigrationHook
|
|||
if (! $this->version) {
|
||||
$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';
|
||||
} elseif (static::tableExists($conn, 'icingaweb_rememberme')) {
|
||||
$randomIvType = static::getColumnType($conn, 'icingaweb_rememberme', 'random_iv');
|
||||
|
|
Loading…
Reference in New Issue