Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
ba99f53f
Commit
ba99f53f
authored
Dec 06, 2009
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-169 - Fix implicit/explicit index creation differences between platforms
parent
bf0ef0d0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
3 deletions
+103
-3
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+5
-0
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+2
-2
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+4
-0
Schema.php
lib/Doctrine/DBAL/Schema/Schema.php
+15
-1
FixSchema.php
lib/Doctrine/DBAL/Schema/Visitor/FixSchema.php
+77
-0
No files found.
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
ba99f53f
...
...
@@ -794,4 +794,9 @@ class MySqlPlatform extends AbstractPlatform
{
return
'mysql'
;
}
public
function
createsExplicitIndexForForeignKeys
()
{
return
true
;
}
}
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
ba99f53f
...
...
@@ -51,7 +51,7 @@ abstract class AbstractSchemaManager
/**
* Holds instance of the database platform used for this schema manager
*
* @var \Doctrine\DBAL\Platform\AbstractPlatform
* @var \Doctrine\DBAL\Platform
s
\AbstractPlatform
*/
protected
$_platform
;
...
...
@@ -936,6 +936,6 @@ abstract class AbstractSchemaManager
}
$tables
=
$this
->
listTables
();
return
new
Schema
(
$tables
,
$sequences
);
return
new
Schema
(
$tables
,
$sequences
,
$this
->
_platform
->
createsExplicitIndexForForeignKeys
()
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
ba99f53f
...
...
@@ -72,6 +72,10 @@ class Comparator
*/
public
function
compare
(
Schema
$fromSchema
,
Schema
$toSchema
)
{
if
(
$fromSchema
->
hasExplicitForeignKeyIndexes
()
&&
!
$toSchema
->
hasExplicitForeignKeyIndexes
())
{
$toSchema
->
visit
(
new
\Doctrine\DBAL\Schema\Visitor\FixSchema
(
true
));
}
$diff
=
new
SchemaDiff
();
$foreignKeysToTable
=
array
();
...
...
lib/Doctrine/DBAL/Schema/Schema.php
View file @
ba99f53f
...
...
@@ -46,11 +46,16 @@ class Schema extends AbstractAsset
*/
protected
$_sequences
=
array
();
/**
* @var bool
*/
protected
$_hasExplicitForeignKeyIndexes
=
false
;
/**
* @param array $tables
* @param array $sequences
*/
public
function
__construct
(
array
$tables
=
array
(),
array
$sequences
=
array
())
public
function
__construct
(
array
$tables
=
array
(),
array
$sequences
=
array
()
,
$hasExplicitForeignKeyIndexes
=
false
)
{
foreach
(
$tables
AS
$table
)
{
$this
->
_addTable
(
$table
);
...
...
@@ -58,6 +63,15 @@ class Schema extends AbstractAsset
foreach
(
$sequences
AS
$sequence
)
{
$this
->
_addSequence
(
$sequence
);
}
$this
->
_hasExplicitForeignKeyIndexes
=
$hasExplicitForeignKeyIndexes
;
}
/**
* @return bool
*/
public
function
hasExplicitForeignKeyIndexes
()
{
return
$this
->
_hasExplicitForeignKeyIndexes
;
}
/**
...
...
lib/Doctrine/DBAL/Schema/Visitor/FixSchema.php
0 → 100644
View file @
ba99f53f
<?php
namespace
Doctrine\DBAL\Schema\Visitor
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Schema
,
Doctrine\DBAL\Schema\Column
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\Constraint
,
Doctrine\DBAL\Schema\Sequence
,
Doctrine\DBAL\Schema\Index
;
class
FixSchema
implements
Visitor
{
/**
* @var bool
*/
private
$_addExplicitIndexForForeignKey
=
null
;
public
function
__construct
(
$addExplicitIndexForForeignKey
)
{
$this
->
_addExplicitIndexForForeignKey
=
$addExplicitIndexForForeignKey
;
}
/**
* @param Schema $schema
*/
public
function
acceptSchema
(
Schema
$schema
)
{
}
/**
* @param Table $table
*/
public
function
acceptTable
(
Table
$table
)
{
}
/**
* @param Column $column
*/
public
function
acceptColunn
(
Table
$table
,
Column
$column
)
{
}
/**
* @param Table $localTable
* @param ForeignKeyConstraint $fkConstraint
*/
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
{
if
(
$this
->
_addExplicitIndexForForeignKey
)
{
$localTable
->
addIndex
(
$fkConstraint
->
getColumns
());
}
}
/**
* @param Table $table
* @param Index $index
*/
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
}
/**
* @param Sequence $sequence
*/
public
function
acceptSequence
(
Sequence
$sequence
)
{
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment