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
34119d39
Commit
34119d39
authored
Dec 06, 2009
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-169 - Fix order that column and index/fk changes are applied in alter table.
parent
58e99d39
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
12 deletions
+24
-12
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+14
-8
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+2
-1
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+2
-1
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+3
-1
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+3
-1
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
34119d39
...
...
@@ -802,29 +802,35 @@ abstract class AbstractPlatform
*/
protected
function
_getAlterTableIndexForeignKeySql
(
TableDiff
$diff
)
{
if
(
$diff
->
newName
!==
false
)
{
$tableName
=
$diff
->
newName
;
}
else
{
$tableName
=
$diff
->
name
;
}
$sql
=
array
();
if
(
$this
->
supportsForeignKeyConstraints
())
{
foreach
(
$diff
->
addedForeignKeys
AS
$foreignKey
)
{
$sql
[]
=
$this
->
getCreateForeignKeySql
(
$foreignKey
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getCreateForeignKeySql
(
$foreignKey
,
$
tableN
ame
);
}
foreach
(
$diff
->
removedForeignKeys
AS
$foreignKey
)
{
$sql
[]
=
$this
->
getDropForeignKeySql
(
$foreignKey
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getDropForeignKeySql
(
$foreignKey
,
$
tableN
ame
);
}
foreach
(
$diff
->
changedForeignKeys
AS
$foreignKey
)
{
$sql
[]
=
$this
->
getDropForeignKeySql
(
$foreignKey
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getCreateForeignKeySql
(
$foreignKey
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getDropForeignKeySql
(
$foreignKey
,
$
tableN
ame
);
$sql
[]
=
$this
->
getCreateForeignKeySql
(
$foreignKey
,
$
tableN
ame
);
}
}
foreach
(
$diff
->
addedIndexes
AS
$index
)
{
$sql
[]
=
$this
->
getCreateIndexSql
(
$index
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getCreateIndexSql
(
$index
,
$
tableN
ame
);
}
foreach
(
$diff
->
removedIndexes
AS
$index
)
{
$sql
[]
=
$this
->
getDropIndexSql
(
$index
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getDropIndexSql
(
$index
,
$
tableN
ame
);
}
foreach
(
$diff
->
changedIndexes
AS
$index
)
{
$sql
[]
=
$this
->
getDropIndexSql
(
$index
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getCreateIndexSql
(
$index
,
$
diff
->
n
ame
);
$sql
[]
=
$this
->
getDropIndexSql
(
$index
,
$
tableN
ame
);
$sql
[]
=
$this
->
getCreateIndexSql
(
$index
,
$
tableN
ame
);
}
return
$sql
;
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
34119d39
...
...
@@ -125,10 +125,11 @@ class MsSqlPlatform extends AbstractPlatform
.
$this
->
getColumnDeclarationSql
(
$column
->
getName
(),
$column
->
toArray
());
}
$sql
=
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
);
$sql
=
array
(
);
if
(
count
(
$queryParts
)
>
0
)
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' '
.
implode
(
", "
,
$queryParts
);
}
$sql
=
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
));
return
$sql
;
}
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
34119d39
...
...
@@ -620,10 +620,11 @@ class MySqlPlatform extends AbstractPlatform
.
$this
->
getColumnDeclarationSql
(
$column
->
getName
(),
$column
->
toArray
());
}
$sql
=
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
);
$sql
=
array
(
);
if
(
count
(
$queryParts
)
>
0
)
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' '
.
implode
(
", "
,
$queryParts
);
}
$sql
=
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
));
return
$sql
;
}
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
34119d39
...
...
@@ -477,7 +477,7 @@ END;';
*/
public
function
getAlterTableSql
(
TableDiff
$diff
)
{
$sql
=
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
);
$sql
=
array
(
);
$fields
=
array
();
foreach
(
$diff
->
addedColumns
AS
$column
)
{
...
...
@@ -512,6 +512,8 @@ END;';
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME TO '
.
$diff
->
newName
;
}
$sql
=
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
));
return
$sql
;
}
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
34119d39
...
...
@@ -493,7 +493,7 @@ class PostgreSqlPlatform extends AbstractPlatform
*/
public
function
getAlterTableSql
(
TableDiff
$diff
)
{
$sql
=
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
);
$sql
=
array
(
);
foreach
(
$diff
->
addedColumns
as
$column
)
{
$query
=
'ADD '
.
$this
->
getColumnDeclarationSql
(
$column
->
getName
(),
$column
->
toArray
());
...
...
@@ -534,6 +534,8 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME TO '
.
$diff
->
newName
;
}
$sql
=
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySql
(
$diff
));
return
$sql
;
}
...
...
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