mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-16 15:08:54 +00:00
[ticket/17528] Fix MySQL platform
PHPBB-17528
This commit is contained in:
parent
9cccf26311
commit
98c6a88438
3 changed files with 64 additions and 0 deletions
|
@ -149,6 +149,7 @@ class connection_parameter_factory
|
|||
$enrichment_tags = [
|
||||
'pdo_mysql' => [
|
||||
'charset' => 'UTF8',
|
||||
'platform' => new mysql_platform(),
|
||||
],
|
||||
'oci8' => [
|
||||
'charset' => 'UTF8',
|
||||
|
|
62
phpBB/phpbb/db/doctrine/mysql_platform.php
Normal file
62
phpBB/phpbb/db/doctrine/mysql_platform.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\doctrine;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||
use Doctrine\DBAL\Schema\TableDiff;
|
||||
|
||||
/**
|
||||
* MySQL specific schema handling.
|
||||
*
|
||||
* While adding auto_increment column to MySQL, it must be indexed.
|
||||
* If it's indexed as primary key, it ahould be declared as NOT NULL
|
||||
* because MySQL primary key columns cannot be NULL.
|
||||
*/
|
||||
class mysql_platform extends AbstractMySQLPlatform
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getAlterTableSQL(TableDiff $diff)
|
||||
{
|
||||
$sql = parent::getAlterTableSQL($diff);
|
||||
$table = $diff->getOldTable();
|
||||
$columns = $diff->getAddedColumns();
|
||||
|
||||
foreach ($columns as $column)
|
||||
{
|
||||
$column_name = $column->getName();
|
||||
if (!empty($column->getAutoincrement()) && $table)
|
||||
{
|
||||
foreach ($sql as $i => $query)
|
||||
{
|
||||
if (stripos($query, "add $column_name"))
|
||||
{
|
||||
if (!$table->getPrimaryKey())
|
||||
{
|
||||
$sql[$i] = str_replace(' DEFAULT NULL', '', $sql[$i]);
|
||||
$sql[$i] .= ' PRIMARY KEY';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql[$i] .= ", ADD KEY ($column_name)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
|
|||
use Doctrine\DBAL\Schema\Index;
|
||||
use Doctrine\DBAL\Schema\Sequence;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Doctrine\DBAL\Schema\TableDiff;
|
||||
use Doctrine\DBAL\Types\BigIntType;
|
||||
use Doctrine\DBAL\Types\IntegerType;
|
||||
use Doctrine\DBAL\Types\SmallIntType;
|
||||
|
|
Loading…
Add table
Reference in a new issue