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
3dae2a5c
Commit
3dae2a5c
authored
Dec 16, 2013
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix renaming columns in DB2
parent
46c95062
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
2 deletions
+40
-2
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+40
-2
No files found.
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
3dae2a5c
...
...
@@ -530,7 +530,7 @@ class DB2Platform extends AbstractPlatform
continue
;
}
$queryParts
[]
=
'RENAME '
.
$oldColumnName
.
' TO '
.
$column
->
getQuotedName
(
$this
);
$queryParts
[]
=
'RENAME
COLUMN
'
.
$oldColumnName
.
' TO '
.
$column
->
getQuotedName
(
$this
);
}
$tableSql
=
array
();
...
...
@@ -540,7 +540,11 @@ class DB2Platform extends AbstractPlatform
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' '
.
implode
(
" "
,
$queryParts
);
}
$sql
=
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySQL
(
$diff
));
$sql
=
array_merge
(
$this
->
getPreAlterTableIndexForeignKeySQL
(
$diff
),
$sql
,
$this
->
getPostAlterTableIndexForeignKeySQL
(
$diff
)
);
if
(
$diff
->
newName
!==
false
)
{
$sql
[]
=
'RENAME TABLE TO '
.
$diff
->
newName
;
...
...
@@ -550,6 +554,40 @@ class DB2Platform extends AbstractPlatform
return
array_merge
(
$sql
,
$tableSql
,
$columnSql
);
}
/**
* {@inheritDoc}
*/
protected
function
getPreAlterTableIndexForeignKeySQL
(
TableDiff
$diff
)
{
$sql
=
array
();
$table
=
$diff
->
name
;
foreach
(
$diff
->
removedIndexes
as
$remKey
=>
$remIndex
)
{
foreach
(
$diff
->
addedIndexes
as
$addKey
=>
$addIndex
)
{
if
(
$remIndex
->
getColumns
()
==
$addIndex
->
getColumns
())
{
if
(
$remIndex
->
isPrimary
())
{
$sql
[]
=
'ALTER TABLE '
.
$table
.
' DROP PRIMARY KEY'
;
}
elseif
(
$remIndex
->
isUnique
())
{
$sql
[]
=
'ALTER TABLE '
.
$table
.
' DROP UNIQUE '
.
$remIndex
->
getQuotedName
(
$this
);
}
else
{
$sql
[]
=
$this
->
getDropIndexSQL
(
$remIndex
,
$table
);
}
$sql
[]
=
$this
->
getCreateIndexSQL
(
$addIndex
,
$table
);
unset
(
$diff
->
removedIndexes
[
$remKey
]);
unset
(
$diff
->
addedIndexes
[
$addKey
]);
break
;
}
}
}
$sql
=
array_merge
(
$sql
,
parent
::
getPreAlterTableIndexForeignKeySQL
(
$diff
));
return
$sql
;
}
/**
* {@inheritDoc}
*/
...
...
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