Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,13 @@ public function getDoctrineColumn($table, $column)
*/
public function getDoctrineSchemaManager()
{
return $this->getDoctrineDriver()->getSchemaManager($this->getDoctrineConnection());
$connection = $this->getDoctrineConnection();

// Doctrine v2 expects one parameter while v3 expects two. 2nd will be ignored on v2...
return $this->getDoctrineDriver()->getSchemaManager(
$connection,
$connection->getDatabasePlatform()
);
}

/**
Expand All @@ -834,9 +840,14 @@ public function getDoctrineConnection()
{
$driver = $this->getDoctrineDriver();

$data = array('pdo' => $this->pdo, 'dbname' => $this->getConfig('database'));

return new DoctrineConnection($data, $driver);
return new DoctrineConnection([
'host' => $this->getConfig('host'),
'port' => $this->getConfig('port'),
'user' => $this->getConfig('username'),
'password' => $this->getConfig('password'),
'dbname' => $this->getDatabaseName(),
'charset' => $this->getConfig('charset'),
], $driver);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/MySqlConnection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace Illuminate\Database;

use Illuminate\Database\Schema\MySqlBuilder;
use Doctrine\DBAL\Driver\PDOMySql\Driver as DoctrineDriver;
use Doctrine\DBAL\Driver\PDO\MySQL\Driver as DoctrineDriver;
use Illuminate\Database\Query\Grammars\MySqlGrammar as QueryGrammar;
use Illuminate\Database\Schema\Grammars\MySqlGrammar as SchemaGrammar;

Expand Down Expand Up @@ -52,7 +52,7 @@ protected function getDefaultPostProcessor()
/**
* Get the Doctrine DBAL driver.
*
* @return \Doctrine\DBAL\Driver\PDOMySql\Driver
* @return \Doctrine\DBAL\Driver\PDO\MySQL\Driver
*/
protected function getDoctrineDriver()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/PostgresConnection.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Illuminate\Database;

use Doctrine\DBAL\Driver\PDOPgSql\Driver as DoctrineDriver;
use Doctrine\DBAL\Driver\PDO\PgSQL\Driver as DoctrineDriver;
use Illuminate\Database\Query\Processors\PostgresProcessor;
use Illuminate\Database\Query\Grammars\PostgresGrammar as QueryGrammar;
use Illuminate\Database\Schema\Grammars\PostgresGrammar as SchemaGrammar;
Expand Down Expand Up @@ -40,7 +40,7 @@ protected function getDefaultPostProcessor()
/**
* Get the Doctrine DBAL driver.
*
* @return \Doctrine\DBAL\Driver\PDOPgSql\Driver
* @return \Doctrine\DBAL\Driver\PDO\PgSQL\Driver
*/
protected function getDoctrineDriver()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/SQLiteConnection.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Illuminate\Database;

use Doctrine\DBAL\Driver\PDOSqlite\Driver as DoctrineDriver;
use Doctrine\DBAL\Driver\PDO\SQLite\Driver as DoctrineDriver;
use Illuminate\Database\Query\Grammars\SQLiteGrammar as QueryGrammar;
use Illuminate\Database\Schema\Grammars\SQLiteGrammar as SchemaGrammar;

Expand Down Expand Up @@ -39,7 +39,7 @@ protected function getDefaultPostProcessor()
/**
* Get the Doctrine DBAL driver.
*
* @return \Doctrine\DBAL\Driver\PDOSqlite\Driver
* @return \Doctrine\DBAL\Driver\PDO\SQLite\Driver
*/
protected function getDoctrineDriver()
{
Expand Down
15 changes: 12 additions & 3 deletions src/Illuminate/Database/Schema/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,22 @@ protected function getRenamedDiff(Blueprint $blueprint, Fluent $command, Column
*/
protected function setRenamedColumns(TableDiff $tableDiff, Fluent $command, Column $column)
{
$newColumn = new Column($command->to, $column->getType(), $column->toArray());

$tableDiff->renamedColumns = array($command->from => $newColumn);
$tableDiff->renamedColumns = array(
$command->from => new Column($command->to, $column->getType(), self::getWritableColumnOptions($column))
);

return $tableDiff;
}

private static function getWritableColumnOptions(Column $column): array
{
return array_filter(
$column->toArray(),
fn (string $name) => method_exists($column, 'set'.$name),
ARRAY_FILTER_USE_KEY
);
}

/**
* Compile a foreign key command.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/SqlServerConnection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace Illuminate\Database;

use Closure;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as DoctrineDriver;
use Doctrine\DBAL\Driver\PDO\SQLSrv\Driver as DoctrineDriver;
use Illuminate\Database\Query\Processors\SqlServerProcessor;
use Illuminate\Database\Query\Grammars\SqlServerGrammar as QueryGrammar;
use Illuminate\Database\Schema\Grammars\SqlServerGrammar as SchemaGrammar;
Expand Down Expand Up @@ -87,7 +87,7 @@ protected function getDefaultPostProcessor()
/**
* Get the Doctrine DBAL Driver.
*
* @return \Doctrine\DBAL\Driver\PDOSqlsrv\Driver
* @return \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver
*/
protected function getDoctrineDriver()
{
Expand Down