Вход Регистрация
Файл: vendor/doctrine/dbal/src/Platforms/SQLite/Comparator.php
Строк: 69
<?php

namespace DoctrineDBALPlatformsSQLite;

use 
DoctrineDBALPlatformsSqlitePlatform;
use 
DoctrineDBALSchemaComparator as BaseComparator;
use 
DoctrineDBALSchemaTable;
use 
DoctrineDBALSchemaTableDiff;

use function 
strcasecmp;

/**
 * Compares schemas in the context of SQLite platform.
 *
 * BINARY is the default column collation and should be ignored if specified explicitly.
 */
class Comparator extends BaseComparator
{
    
/** @internal The comparator can be only instantiated by a schema manager. */
    
public function __construct(SqlitePlatform $platform)
    {
        
parent::__construct($platform);
    }

    public function 
compareTables(Table $fromTableTable $toTable): TableDiff
    
{
        return 
parent::compareTables(
            
$this->normalizeColumns($fromTable),
            
$this->normalizeColumns($toTable),
        );
    }

    
/**
     * {@inheritDoc}
     */
    
public function diffTable(Table $fromTableTable $toTable)
    {
        return 
parent::diffTable(
            
$this->normalizeColumns($fromTable),
            
$this->normalizeColumns($toTable),
        );
    }

    private function 
normalizeColumns(Table $table): Table
    
{
        
$table = clone $table;

        foreach (
$table->getColumns() as $column) {
            
$options $column->getPlatformOptions();

            if (! isset(
$options['collation']) || strcasecmp($options['collation'], 'binary') !== 0) {
                continue;
            }

            unset(
$options['collation']);
            
$column->setPlatformOptions($options);
        }

        return 
$table;
    }
}
Онлайн: 0
Реклама