1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-24 02:21:43 +02:00
Files
php-phpbb/phpBB/phpbb/db/doctrine/comparator.php
Tristan Darricau b8d555f56a [ticket/16741] Specific DBs fixes
MSSQL:
- Fix bool type
- Fix comparator
- Drop Default constraint before deleting column
- Rename Default constraint to use phpBB's names
- Re-create the indices when changing the type of one column
- Uses varchar instead of varbinary

PostgreSQL:
- Creates auto increment sequences by hand instead of using serial
  in order to use phpBB's names
- Drop constraint on unique / primary indices

Oracle:
- Rename indices to use phpBB's names
- Fix string not null behaviour
- Fix broken regex in Oracle driver
- Handle to long indices on Oracle
- Rename auto_increment trigger and sequence
- Automatically lowercase keys in assoc results

PHPBB3-16741
2021-11-11 04:55:28 +01:00

65 lines
1.3 KiB
PHP

<?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\Schema\Table;
class comparator extends \Doctrine\DBAL\Schema\Comparator
{
/**
* {@inerhitDoc}
*/
public function diffTable(Table $fromTable, Table $toTable)
{
$diff = parent::diffTable($fromTable, $toTable);
if ($diff === false)
{
return $diff;
}
if (!is_array($diff->changedColumns))
{
return $diff;
}
// When the type of a column changes, re-create the associated indices
foreach ($diff->changedColumns as $columnName => $changedColumn)
{
if (!$changedColumn->hasChanged('type'))
{
continue;
}
foreach ($toTable->getIndexes() as $index_name => $index)
{
if (array_key_exists($index_name, $diff->addedIndexes) || array_key_exists($index_name, $diff->changedIndexes))
{
continue;
}
$index_columns = array_map('strtolower', $index->getUnquotedColumns());
if (array_search($columnName, $index_columns, true) === false)
{
continue;
}
$diff->changedIndexes[$index_name] = $index;
}
}
return $diff;
}
}