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
6d0e8e2a
Commit
6d0e8e2a
authored
Dec 29, 2013
by
Steve Müller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #473 from deeky666/DBAL-234
[DBAL-234] [DBAL-566] Add support for renaming indexes
parents
fba268be
7ed642dc
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
858 additions
and
7 deletions
+858
-7
platforms.rst
docs/en/reference/platforms.rst
+1
-0
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+29
-0
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+8
-1
MySQL57Keywords.php
lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php
+281
-0
MySQL57Platform.php
lib/Doctrine/DBAL/Platforms/MySQL57Platform.php
+50
-0
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+8
-0
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+9
-0
SQLAnywherePlatform.php
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
+10
-0
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+15
-1
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+2
-1
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+5
-0
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+46
-0
TableDiff.php
lib/Doctrine/DBAL/Schema/TableDiff.php
+7
-0
ReservedWordsCommand.php
...trine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
+3
-0
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+16
-2
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+64
-0
DB2PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
+21
-0
MySQL57PlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
+37
-0
MySqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
+24
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+21
-0
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+21
-0
SQLAnywherePlatformTest.php
...Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+21
-0
SQLServerPlatformTest.php
...s/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
+21
-0
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+31
-0
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+7
-2
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+100
-0
No files found.
docs/en/reference/platforms.rst
View file @
6d0e8e2a
...
...
@@ -34,6 +34,7 @@ MySQL
^^^^^
- ``MySqlPlatform`` for version 5.0 and above.
- ``MySQL57Platform`` for version 5.7 and above.
Oracle
^^^^^^
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
6d0e8e2a
...
...
@@ -21,6 +21,7 @@ namespace Doctrine\DBAL\Platforms;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Schema\Identifier
;
use
Doctrine\DBAL\Types
;
use
Doctrine\DBAL\Schema\Constraint
;
use
Doctrine\DBAL\Schema\Sequence
;
...
...
@@ -1823,10 +1824,12 @@ abstract class AbstractPlatform
:
$diff
->
getName
()
->
getQuotedName
(
$this
);
$sql
=
array
();
if
(
$this
->
supportsForeignKeyConstraints
())
{
foreach
(
$diff
->
addedForeignKeys
as
$foreignKey
)
{
$sql
[]
=
$this
->
getCreateForeignKeySQL
(
$foreignKey
,
$tableName
);
}
foreach
(
$diff
->
changedForeignKeys
as
$foreignKey
)
{
$sql
[]
=
$this
->
getCreateForeignKeySQL
(
$foreignKey
,
$tableName
);
}
...
...
@@ -1835,13 +1838,39 @@ abstract class AbstractPlatform
foreach
(
$diff
->
addedIndexes
as
$index
)
{
$sql
[]
=
$this
->
getCreateIndexSQL
(
$index
,
$tableName
);
}
foreach
(
$diff
->
changedIndexes
as
$index
)
{
$sql
[]
=
$this
->
getCreateIndexSQL
(
$index
,
$tableName
);
}
foreach
(
$diff
->
renamedIndexes
as
$oldIndexName
=>
$index
)
{
$oldIndexName
=
new
Identifier
(
$oldIndexName
);
$sql
=
array_merge
(
$sql
,
$this
->
getRenameIndexSQL
(
$oldIndexName
->
getQuotedName
(
$this
),
$index
,
$tableName
)
);
}
return
$sql
;
}
/**
* Returns the SQL for renaming an index on a table.
*
* @param string $oldIndexName The name of the index to rename from.
* @param \Doctrine\DBAL\Schema\Index $index The definition of the index to rename to.
* @param string $tableName The table to rename the given index on.
*
* @return array The sequence of SQL statements for renaming the given index.
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
return
array
(
$this
->
getDropIndexSQL
(
$oldIndexName
,
$tableName
),
$this
->
getCreateIndexSQL
(
$index
,
$tableName
)
);
}
/**
* Common code for alter table statement generation that updates the changed Index and Foreign Key definitions.
*
...
...
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
6d0e8e2a
...
...
@@ -19,7 +19,6 @@
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\TableDiff
;
...
...
@@ -575,6 +574,14 @@ class DB2Platform extends AbstractPlatform
return
$sql
;
}
/**
* {@inheritdoc}
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
return
array
(
'RENAME INDEX '
.
$oldIndexName
.
' TO '
.
$index
->
getQuotedName
(
$this
));
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/Keywords/MySQL57Keywords.php
0 → 100644
View file @
6d0e8e2a
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms\Keywords
;
/**
* MySQL 5.7 reserved keywords list.
*
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org
* @since 2.5
*/
class
MySQL57Keywords
extends
MySQLKeywords
{
/**
* {@inheritdoc}
*/
public
function
getName
()
{
return
'MySQL57'
;
}
/**
* {@inheritdoc}
*
* @link http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-7.html
*/
protected
function
getKeywords
()
{
return
array
(
'ACCESSIBLE'
,
'ADD'
,
'ALL'
,
'ALTER'
,
'ANALYZE'
,
'AND'
,
'AS'
,
'ASC'
,
'ASENSITIVE'
,
'BEFORE'
,
'BETWEEN'
,
'BIGINT'
,
'BINARY'
,
'BLOB'
,
'BOTH'
,
'BY'
,
'CALL'
,
'CASCADE'
,
'CASE'
,
'CHANGE'
,
'CHAR'
,
'CHARACTER'
,
'CHECK'
,
'COLLATE'
,
'COLUMN'
,
'CONDITION'
,
'CONSTRAINT'
,
'CONTINUE'
,
'CONVERT'
,
'CREATE'
,
'CROSS'
,
'CURRENT_DATE'
,
'CURRENT_TIME'
,
'CURRENT_TIMESTAMP'
,
'CURRENT_USER'
,
'CURSOR'
,
'DATABASE'
,
'DATABASES'
,
'DAY_HOUR'
,
'DAY_MICROSECOND'
,
'DAY_MINUTE'
,
'DAY_SECOND'
,
'DEC'
,
'DECIMAL'
,
'DECLARE'
,
'DEFAULT'
,
'DELAYED'
,
'DELETE'
,
'DESC'
,
'DESCRIBE'
,
'DETERMINISTIC'
,
'DISTINCT'
,
'DISTINCTROW'
,
'DIV'
,
'DOUBLE'
,
'DROP'
,
'DUAL'
,
'EACH'
,
'ELSE'
,
'ELSEIF'
,
'ENCLOSED'
,
'ESCAPED'
,
'EXISTS'
,
'EXIT'
,
'EXPLAIN'
,
'FALSE'
,
'FETCH'
,
'FLOAT'
,
'FLOAT4'
,
'FLOAT8'
,
'FOR'
,
'FORCE'
,
'FOREIGN'
,
'FROM'
,
'FULLTEXT'
,
'GET'
,
'GRANT'
,
'GROUP'
,
'HAVING'
,
'HIGH_PRIORITY'
,
'HOUR_MICROSECOND'
,
'HOUR_MINUTE'
,
'HOUR_SECOND'
,
'IF'
,
'IGNORE'
,
'IN'
,
'INDEX'
,
'INFILE'
,
'INNER'
,
'INOUT'
,
'INSENSITIVE'
,
'INSERT'
,
'INT'
,
'INT1'
,
'INT2'
,
'INT3'
,
'INT4'
,
'INT8'
,
'INTEGER'
,
'INTERVAL'
,
'INTO'
,
'IO_AFTER_GTIDS'
,
'IO_BEFORE_GTIDS'
,
'IS'
,
'ITERATE'
,
'JOIN'
,
'KEY'
,
'KEYS'
,
'KILL'
,
'LEADING'
,
'LEAVE'
,
'LEFT'
,
'LIKE'
,
'LIMIT'
,
'LINEAR'
,
'LINES'
,
'LOAD'
,
'LOCALTIME'
,
'LOCALTIMESTAMP'
,
'LOCK'
,
'LONG'
,
'LONGBLOB'
,
'LONGTEXT'
,
'LOOP'
,
'LOW_PRIORITY'
,
'MASTER_BIND'
,
'MASTER_SSL_VERIFY_SERVER_CERT'
,
'MATCH'
,
'MAXVALUE'
,
'MEDIUMBLOB'
,
'MEDIUMINT'
,
'MEDIUMTEXT'
,
'MIDDLEINT'
,
'MINUTE_MICROSECOND'
,
'MINUTE_SECOND'
,
'MOD'
,
'MODIFIES'
,
'NATURAL'
,
'NO_WRITE_TO_BINLOG'
,
'NONBLOCKING'
,
'NOT'
,
'NULL'
,
'NUMERIC'
,
'ON'
,
'OPTIMIZE'
,
'OPTION'
,
'OPTIONALLY'
,
'OR'
,
'ORDER'
,
'OUT'
,
'OUTER'
,
'OUTFILE'
,
'PARTITION'
,
'PRECISION'
,
'PRIMARY'
,
'PROCEDURE'
,
'PURGE'
,
'RANGE'
,
'READ'
,
'READ_WRITE'
,
'READS'
,
'REAL'
,
'REFERENCES'
,
'REGEXP'
,
'RELEASE'
,
'RENAME'
,
'REPEAT'
,
'REPLACE'
,
'REQUIRE'
,
'RESIGNAL'
,
'RESTRICT'
,
'RETURN'
,
'REVOKE'
,
'RIGHT'
,
'RLIKE'
,
'SCHEMA'
,
'SCHEMAS'
,
'SECOND_MICROSECOND'
,
'SELECT'
,
'SENSITIVE'
,
'SEPARATOR'
,
'SET'
,
'SHOW'
,
'SIGNAL'
,
'SMALLINT'
,
'SPATIAL'
,
'SPECIFIC'
,
'SQL'
,
'SQL_BIG_RESULT'
,
'SQL_CALC_FOUND_ROWS'
,
'SQL_SMALL_RESULT'
,
'SQLEXCEPTION'
,
'SQLSTATE'
,
'SQLWARNING'
,
'SSL'
,
'STARTING'
,
'STRAIGHT_JOIN'
,
'TABLE'
,
'TERMINATED'
,
'THEN'
,
'TINYBLOB'
,
'TINYINT'
,
'TINYTEXT'
,
'TO'
,
'TRAILING'
,
'TRIGGER'
,
'TRUE'
,
'UNDO'
,
'UNION'
,
'UNIQUE'
,
'UNLOCK'
,
'UNSIGNED'
,
'UPDATE'
,
'USAGE'
,
'USE'
,
'USING'
,
'UTC_DATE'
,
'UTC_TIME'
,
'UTC_TIMESTAMP'
,
'VALUES'
,
'VARBINARY'
,
'VARCHAR'
,
'VARCHARACTER'
,
'VARYING'
,
'WHEN'
,
'WHERE'
,
'WHILE'
,
'WITH'
,
'WRITE'
,
'XOR'
,
'YEAR_MONTH'
,
'ZEROFILL'
,
);
}
}
lib/Doctrine/DBAL/Platforms/MySQL57Platform.php
0 → 100644
View file @
6d0e8e2a
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\DBAL\Schema\Index
;
/**
* Provides the behavior, features and SQL dialect of the MySQL 5.7 database platform.
*
* @author Steve Müller <st.mueller@dzh-online.de>
* @link www.doctrine-project.org
* @since 2.5
*/
class
MySQL57Platform
extends
MySqlPlatform
{
/**
* {@inheritdoc}
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
return
array
(
'ALTER TABLE '
.
$tableName
.
' RENAME INDEX '
.
$oldIndexName
.
' TO '
.
$index
->
getQuotedName
(
$this
)
);
}
/**
* {@inheritdoc}
*/
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords'
;
}
}
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
6d0e8e2a
...
...
@@ -762,6 +762,14 @@ LEFT JOIN user_cons_columns r_cols
return
$name
.
' '
.
$columnDef
;
}
/**
* {@inheritdoc}
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
return
array
(
'ALTER INDEX '
.
$oldIndexName
.
' RENAME TO '
.
$index
->
getQuotedName
(
$this
));
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
6d0e8e2a
...
...
@@ -21,6 +21,7 @@ namespace Doctrine\DBAL\Platforms;
use
Doctrine\DBAL\Schema\Column
;
use
Doctrine\DBAL\Schema\ColumnDiff
;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\Types\BinaryType
;
use
Doctrine\DBAL\Types\BlobType
;
...
...
@@ -582,6 +583,14 @@ class PostgreSqlPlatform extends AbstractPlatform
return
count
(
array_diff
(
$columnDiff
->
changedProperties
,
array
(
'length'
,
'fixed'
)))
===
0
;
}
/**
* {@inheritdoc}
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
return
array
(
'ALTER INDEX '
.
$oldIndexName
.
' RENAME TO '
.
$index
->
getQuotedName
(
$this
));
}
/**
* {@inheritdoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php
View file @
6d0e8e2a
...
...
@@ -1449,6 +1449,16 @@ class SQLAnywherePlatform extends AbstractPlatform
return
$type
;
}
/**
* {@inheritdoc}
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
return
array
(
'ALTER INDEX '
.
$oldIndexName
.
' ON '
.
$tableName
.
' RENAME TO '
.
$index
->
getQuotedName
(
$this
)
);
}
/**
* {@inheritdoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
6d0e8e2a
...
...
@@ -22,7 +22,6 @@ namespace Doctrine\DBAL\Platforms;
use
Doctrine\DBAL\LockMode
;
use
Doctrine\DBAL\Schema\Column
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\Table
;
...
...
@@ -659,6 +658,21 @@ class SQLServerPlatform extends AbstractPlatform
);
}
/**
* {@inheritdoc}
*/
protected
function
getRenameIndexSQL
(
$oldIndexName
,
Index
$index
,
$tableName
)
{
return
array
(
sprintf
(
"EXEC sp_RENAME N'%s.%s', N'%s', N'INDEX'"
,
$tableName
,
$oldIndexName
,
$index
->
getQuotedName
(
$this
)
)
);
}
/**
* Returns the SQL statement for adding an extended property to a database object.
*
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
6d0e8e2a
...
...
@@ -849,6 +849,7 @@ class SqlitePlatform extends AbstractPlatform
if
(
!
empty
(
$diff
->
renamedColumns
)
||
!
empty
(
$diff
->
addedForeignKeys
)
||
!
empty
(
$diff
->
addedIndexes
)
||
!
empty
(
$diff
->
changedColumns
)
||
!
empty
(
$diff
->
changedForeignKeys
)
||
!
empty
(
$diff
->
changedIndexes
)
||
!
empty
(
$diff
->
removedColumns
)
||
!
empty
(
$diff
->
removedForeignKeys
)
||
!
empty
(
$diff
->
removedIndexes
)
||
!
empty
(
$diff
->
renamedIndexes
)
)
{
return
false
;
}
...
...
@@ -969,7 +970,7 @@ class SqlitePlatform extends AbstractPlatform
}
}
foreach
(
array_merge
(
$diff
->
changedIndexes
,
$diff
->
addedIndexes
)
as
$index
)
{
foreach
(
array_merge
(
$diff
->
changedIndexes
,
$diff
->
addedIndexes
,
$diff
->
renamedIndexes
)
as
$index
)
{
$indexName
=
strtolower
(
$index
->
getName
());
if
(
strlen
(
$indexName
))
{
$indexes
[
$indexName
]
=
$index
;
...
...
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
6d0e8e2a
...
...
@@ -227,6 +227,11 @@ class Comparator
foreach
(
$table2Indexes
as
$index2Name
=>
$index2Definition
)
{
foreach
(
$table1Indexes
as
$index1Name
=>
$index1Definition
)
{
if
(
$this
->
diffIndex
(
$index1Definition
,
$index2Definition
)
===
false
)
{
if
(
!
$index1Definition
->
isPrimary
()
&&
$index1Name
!=
$index2Name
)
{
$tableDifferences
->
renamedIndexes
[
$index1Name
]
=
$index2Definition
;
$changes
++
;
}
unset
(
$table1Indexes
[
$index1Name
]);
unset
(
$table2Indexes
[
$index2Name
]);
}
else
{
...
...
lib/Doctrine/DBAL/Schema/Table.php
View file @
6d0e8e2a
...
...
@@ -206,6 +206,52 @@ class Table extends AbstractAsset
return
$this
->
_createIndex
(
$columnNames
,
$indexName
,
true
,
false
);
}
/**
* Renames an index.
*
* @param string $oldIndexName The name of the index to rename from.
* @param string|null $newIndexName The name of the index to rename to.
* If null is given, the index name will be auto-generated.
*
* @return \Doctrine\DBAL\Schema\Table This table instance.
*
* @throws SchemaException if no index exists for the given current name
* or if an index with the given new name already exists on this table.
*/
public
function
renameIndex
(
$oldIndexName
,
$newIndexName
=
null
)
{
$oldIndexName
=
strtolower
(
$oldIndexName
);
$normalizedNewIndexName
=
strtolower
(
$newIndexName
);
if
(
$oldIndexName
===
$normalizedNewIndexName
)
{
return
$this
;
}
if
(
!
$this
->
hasIndex
(
$oldIndexName
))
{
throw
SchemaException
::
indexDoesNotExist
(
$oldIndexName
,
$this
->
_name
);
}
if
(
$this
->
hasIndex
(
$normalizedNewIndexName
))
{
throw
SchemaException
::
indexAlreadyExists
(
$normalizedNewIndexName
,
$this
->
_name
);
}
$oldIndex
=
$this
->
_indexes
[
$oldIndexName
];
if
(
$oldIndex
->
isPrimary
())
{
$this
->
dropPrimaryKey
();
return
$this
->
setPrimaryKey
(
$oldIndex
->
getColumns
(),
$newIndexName
);
}
unset
(
$this
->
_indexes
[
$oldIndexName
]);
if
(
$oldIndex
->
isUnique
())
{
return
$this
->
addUniqueIndex
(
$oldIndex
->
getColumns
(),
$newIndexName
);
}
return
$this
->
addIndex
(
$oldIndex
->
getColumns
(),
$newIndexName
,
$oldIndex
->
getFlags
());
}
/**
* Checks if an index begins in the order of the given columns.
*
...
...
lib/Doctrine/DBAL/Schema/TableDiff.php
View file @
6d0e8e2a
...
...
@@ -87,6 +87,13 @@ class TableDiff
*/
public
$removedIndexes
=
array
();
/**
* Indexes that are only renamed but are identical otherwise.
*
* @var \Doctrine\DBAL\Schema\Index[]
*/
public
$renamedIndexes
=
array
();
/**
* All added foreign key definitions
*
...
...
lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php
View file @
6d0e8e2a
...
...
@@ -33,6 +33,7 @@ class ReservedWordsCommand extends Command
*/
private
$keywordListClasses
=
array
(
'mysql'
=>
'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords'
,
'mysql57'
=>
'Doctrine\DBAL\Platforms\Keywords\MySQL57Keywords'
,
'sqlserver'
=>
'Doctrine\DBAL\Platforms\Keywords\SQLServerKeywords'
,
'sqlserver2005'
=>
'Doctrine\DBAL\Platforms\Keywords\SQLServer2005Keywords'
,
'sqlserver2008'
=>
'Doctrine\DBAL\Platforms\Keywords\SQLServer2008Keywords'
,
...
...
@@ -91,6 +92,7 @@ pass them to the command:
The following keyword lists are currently shipped with Doctrine:
* mysql
* mysql57
* pgsql
* pgsql92
* sqlite
...
...
@@ -120,6 +122,7 @@ EOT
if
(
!
$keywordLists
)
{
$keywordLists
=
array
(
'mysql'
,
'mysql57'
,
'pgsql'
,
'pgsql92'
,
'sqlite'
,
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
6d0e8e2a
...
...
@@ -425,7 +425,21 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$tableDiff
=
new
\Doctrine\DBAL\Schema\TableDiff
(
"alter_table"
);
$tableDiff
->
fromTable
=
$table
;
$tableDiff
->
removedIndexes
[]
=
new
\Doctrine\DBAL\Schema\Index
(
'foo_idx'
,
array
(
'foo'
,
'foreign_key_test'
));
$tableDiff
->
renamedIndexes
[
'foo_idx'
]
=
new
\Doctrine\DBAL\Schema\Index
(
'bar_idx'
,
array
(
'foo'
,
'foreign_key_test'
));
$this
->
_sm
->
alterTable
(
$tableDiff
);
$table
=
$this
->
_sm
->
listTableDetails
(
'alter_table'
);
$this
->
assertEquals
(
2
,
count
(
$table
->
getIndexes
()));
$this
->
assertTrue
(
$table
->
hasIndex
(
'bar_idx'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'foo_idx'
));
$this
->
assertEquals
(
array
(
'foo'
,
'foreign_key_test'
),
array_map
(
'strtolower'
,
$table
->
getIndex
(
'bar_idx'
)
->
getColumns
()));
$this
->
assertFalse
(
$table
->
getIndex
(
'bar_idx'
)
->
isPrimary
());
$this
->
assertFalse
(
$table
->
getIndex
(
'bar_idx'
)
->
isUnique
());
$tableDiff
=
new
\Doctrine\DBAL\Schema\TableDiff
(
"alter_table"
);
$tableDiff
->
fromTable
=
$table
;
$tableDiff
->
removedIndexes
[]
=
new
\Doctrine\DBAL\Schema\Index
(
'bar_idx'
,
array
(
'foo'
,
'foreign_key_test'
));
$fk
=
new
\Doctrine\DBAL\Schema\ForeignKeyConstraint
(
array
(
'foreign_key_test'
),
'alter_table_foreign'
,
array
(
'id'
));
$tableDiff
->
addedForeignKeys
[]
=
$fk
;
...
...
@@ -433,7 +447,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$table
=
$this
->
_sm
->
listTableDetails
(
'alter_table'
);
// dont check for index size here, some platforms automatically add indexes for foreign keys.
$this
->
assertFalse
(
$table
->
hasIndex
(
'
foo
_idx'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'
bar
_idx'
));
if
(
$this
->
_sm
->
getDatabasePlatform
()
->
supportsForeignKeyConstraints
())
{
$fks
=
$table
->
getForeignKeys
();
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
6d0e8e2a
...
...
@@ -6,6 +6,7 @@ use Doctrine\Common\EventManager;
use
Doctrine\DBAL\Events
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
use
Doctrine\DBAL\Schema\Index
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\Types\Type
;
...
...
@@ -601,4 +602,67 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this
->
_platform
->
getJsonTypeDeclarationSQL
(
$column
)
);
}
/**
* @group DBAL-234
*/
public
function
testAlterTableRenameIndex
()
{
$tableDiff
=
new
TableDiff
(
'mytable'
);
$tableDiff
->
fromTable
=
new
Table
(
'mytable'
);
$tableDiff
->
fromTable
->
addColumn
(
'id'
,
'integer'
);
$tableDiff
->
fromTable
->
setPrimaryKey
(
array
(
'id'
));
$tableDiff
->
renamedIndexes
=
array
(
'idx_foo'
=>
new
Index
(
'idx_bar'
,
array
(
'id'
))
);
$this
->
assertSame
(
$this
->
getAlterTableRenameIndexSQL
(),
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
)
);
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'DROP INDEX idx_foo'
,
'CREATE INDEX idx_bar ON mytable (id)'
,
);
}
/**
* @group DBAL-234
*/
public
function
testQuotesAlterTableRenameIndex
()
{
$tableDiff
=
new
TableDiff
(
'table'
);
$tableDiff
->
fromTable
=
new
Table
(
'table'
);
$tableDiff
->
fromTable
->
addColumn
(
'id'
,
'integer'
);
$tableDiff
->
fromTable
->
setPrimaryKey
(
array
(
'id'
));
$tableDiff
->
renamedIndexes
=
array
(
'create'
=>
new
Index
(
'select'
,
array
(
'id'
)),
'`foo`'
=>
new
Index
(
'`bar`'
,
array
(
'id'
)),
);
$this
->
assertSame
(
$this
->
getQuotedAlterTableRenameIndexSQL
(),
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
)
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'DROP INDEX "create"'
,
'CREATE INDEX "select" ON "table" (id)'
,
'DROP INDEX "foo"'
,
'CREATE INDEX "bar" ON "table" (id)'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
View file @
6d0e8e2a
...
...
@@ -384,4 +384,25 @@ class DB2PlatformTest extends AbstractPlatformTestCase
$this
->
assertSame
(
'BINARY(32704)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
32704
)));
$this
->
assertSame
(
'BLOB(1M)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
32705
)));
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'RENAME INDEX idx_foo TO idx_bar'
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'RENAME INDEX "create" TO "select"'
,
'RENAME INDEX "foo" TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
0 → 100644
View file @
6d0e8e2a
<?php
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\Platforms\MySQL57Platform
;
class
MySQL57PlatformTest
extends
MySqlPlatformTest
{
/**
* {@inheritdoc}
*/
public
function
createPlatform
()
{
return
new
MySQL57Platform
();
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER TABLE mytable RENAME INDEX idx_foo TO idx_bar'
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER TABLE `table` RENAME INDEX `create` TO `select`'
,
'ALTER TABLE `table` RENAME INDEX `foo` TO `bar`'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
View file @
6d0e8e2a
...
...
@@ -484,4 +484,28 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
)
);
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'DROP INDEX idx_foo ON mytable'
,
'CREATE INDEX idx_bar ON mytable (id)'
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'DROP INDEX `create` ON `table`'
,
'CREATE INDEX `select` ON `table` (id)'
,
'DROP INDEX `foo` ON `table`'
,
'CREATE INDEX `bar` ON `table` (id)'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
6d0e8e2a
...
...
@@ -417,4 +417,25 @@ class OraclePlatformTest extends AbstractPlatformTestCase
array
(
3
,
'CACHE 3'
)
);
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER INDEX idx_foo RENAME TO idx_bar'
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER INDEX "create" RENAME TO "select"'
,
'ALTER INDEX "foo" RENAME TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
6d0e8e2a
...
...
@@ -506,4 +506,25 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
// BLOB -> BLOB
$this
->
assertEmpty
(
$this
->
_platform
->
getAlterTableSQL
(
$comparator
->
diffTable
(
$table1
,
$table2
)));
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER INDEX idx_foo RENAME TO idx_bar'
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER INDEX "create" RENAME TO "select"'
,
'ALTER INDEX "foo" RENAME TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
View file @
6d0e8e2a
...
...
@@ -784,4 +784,25 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
$this
->
assertSame
(
'BINARY(32767)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
32767
)));
$this
->
assertSame
(
'LONG BINARY'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
32768
)));
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER INDEX idx_foo ON mytable RENAME TO idx_bar'
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'ALTER INDEX "create" ON "table" RENAME TO "select"'
,
'ALTER INDEX "foo" ON "table" RENAME TO "bar"'
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
View file @
6d0e8e2a
...
...
@@ -694,4 +694,25 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
$this
->
assertSame
(
'BINARY(8000)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
8000
)));
$this
->
assertSame
(
'VARBINARY(MAX)'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
8001
)));
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
"EXEC sp_RENAME N'mytable.idx_foo', N'idx_bar', N'INDEX'"
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
"EXEC sp_RENAME N'[table].[create]', N'[select]', N'INDEX'"
,
"EXEC sp_RENAME N'[table].[foo]', N'[bar]', N'INDEX'"
,
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
6d0e8e2a
...
...
@@ -323,4 +323,35 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
$this
->
assertSame
(
'BLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
0
)));
$this
->
assertSame
(
'BLOB'
,
$this
->
_platform
->
getBinaryTypeDeclarationSQL
(
array
(
'fixed'
=>
true
,
'length'
=>
9999999
)));
}
/**
* @group DBAL-234
*/
protected
function
getAlterTableRenameIndexSQL
()
{
return
array
(
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id FROM mytable'
,
'DROP TABLE mytable'
,
'CREATE TABLE mytable (id INTEGER NOT NULL, PRIMARY KEY(id))'
,
'INSERT INTO mytable (id) SELECT id FROM __temp__mytable'
,
'DROP TABLE __temp__mytable'
,
'CREATE INDEX idx_bar ON mytable (id)'
,
);
}
/**
* @group DBAL-234
*/
protected
function
getQuotedAlterTableRenameIndexSQL
()
{
return
array
(
'CREATE TEMPORARY TABLE __temp__table AS SELECT id FROM "table"'
,
'DROP TABLE "table"'
,
'CREATE TABLE "table" (id INTEGER NOT NULL, PRIMARY KEY(id))'
,
'INSERT INTO "table" (id) SELECT id FROM __temp__table'
,
'DROP TABLE __temp__table'
,
'CREATE INDEX "select" ON table (id)'
,
'CREATE INDEX "bar" ON table (id)'
,
);
}
}
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
6d0e8e2a
...
...
@@ -617,9 +617,14 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$tableB
->
addIndex
(
array
(
"id"
),
"bar_foo_idx"
);
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
$tableDiff
=
new
TableDiff
(
'foo'
);
$tableDiff
->
fromTable
=
$tableA
;
$tableDiff
->
renamedIndexes
[
'foo_bar_idx'
]
=
new
Index
(
'bar_foo_idx'
,
array
(
'id'
));
$this
->
assertFalse
(
$tableDiff
);
$this
->
assertEquals
(
$tableDiff
,
$c
->
diffTable
(
$tableA
,
$tableB
)
);
}
public
function
testCompareForeignKeyBasedOnPropertiesNotName
()
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
6d0e8e2a
...
...
@@ -525,4 +525,104 @@ class TableTest extends \Doctrine\Tests\DbalTestCase
$table
->
dropPrimaryKey
();
$this
->
assertFalse
(
$table
->
hasPrimaryKey
());
}
/**
* @group DBAL-234
*/
public
function
testRenameIndex
()
{
$table
=
new
Table
(
"test"
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addColumn
(
'foo'
,
'integer'
);
$table
->
addColumn
(
'bar'
,
'integer'
);
$table
->
addColumn
(
'baz'
,
'integer'
);
$table
->
setPrimaryKey
(
array
(
'id'
),
'pk'
);
$table
->
addIndex
(
array
(
'foo'
),
'idx'
,
array
(
'flag'
));
$table
->
addUniqueIndex
(
array
(
'bar'
,
'baz'
),
'uniq'
);
// Rename to custom name.
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'pk'
,
'pk_new'
));
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'idx'
,
'idx_new'
));
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'uniq'
,
'uniq_new'
));
$this
->
assertTrue
(
$table
->
hasPrimaryKey
());
$this
->
assertTrue
(
$table
->
hasIndex
(
'pk_new'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'idx_new'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'uniq_new'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'pk'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'idx'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'uniq'
));
$this
->
assertEquals
(
new
Index
(
'pk_new'
,
array
(
'id'
),
true
,
true
),
$table
->
getPrimaryKey
());
$this
->
assertEquals
(
new
Index
(
'pk_new'
,
array
(
'id'
),
true
,
true
),
$table
->
getIndex
(
'pk_new'
));
$this
->
assertEquals
(
new
Index
(
'idx_new'
,
array
(
'foo'
),
false
,
false
,
array
(
'flag'
)),
$table
->
getIndex
(
'idx_new'
)
);
$this
->
assertEquals
(
new
Index
(
'uniq_new'
,
array
(
'bar'
,
'baz'
),
true
),
$table
->
getIndex
(
'uniq_new'
));
// Rename to auto-generated name.
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'pk_new'
,
null
));
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'idx_new'
,
null
));
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'uniq_new'
,
null
));
$this
->
assertTrue
(
$table
->
hasPrimaryKey
());
$this
->
assertTrue
(
$table
->
hasIndex
(
'primary'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'IDX_D87F7E0C8C736521'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'UNIQ_D87F7E0C76FF8CAA78240498'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'pk_new'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'idx_new'
));
$this
->
assertFalse
(
$table
->
hasIndex
(
'uniq_new'
));
$this
->
assertEquals
(
new
Index
(
'primary'
,
array
(
'id'
),
true
,
true
),
$table
->
getPrimaryKey
());
$this
->
assertEquals
(
new
Index
(
'primary'
,
array
(
'id'
),
true
,
true
),
$table
->
getIndex
(
'primary'
));
$this
->
assertEquals
(
new
Index
(
'IDX_D87F7E0C8C736521'
,
array
(
'foo'
),
false
,
false
,
array
(
'flag'
)),
$table
->
getIndex
(
'IDX_D87F7E0C8C736521'
)
);
$this
->
assertEquals
(
new
Index
(
'UNIQ_D87F7E0C76FF8CAA78240498'
,
array
(
'bar'
,
'baz'
),
true
),
$table
->
getIndex
(
'UNIQ_D87F7E0C76FF8CAA78240498'
)
);
// Rename to same name (changed case).
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'primary'
,
'PRIMARY'
));
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'IDX_D87F7E0C8C736521'
,
'idx_D87F7E0C8C736521'
));
$this
->
assertSame
(
$table
,
$table
->
renameIndex
(
'UNIQ_D87F7E0C76FF8CAA78240498'
,
'uniq_D87F7E0C76FF8CAA78240498'
));
$this
->
assertTrue
(
$table
->
hasPrimaryKey
());
$this
->
assertTrue
(
$table
->
hasIndex
(
'primary'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'IDX_D87F7E0C8C736521'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'UNIQ_D87F7E0C76FF8CAA78240498'
));
}
/**
* @group DBAL-234
* @expectedException \Doctrine\DBAL\Schema\SchemaException
*/
public
function
testThrowsExceptionOnRenamingNonExistingIndex
()
{
$table
=
new
Table
(
"test"
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addIndex
(
array
(
'id'
),
'idx'
);
$table
->
renameIndex
(
'foo'
,
'bar'
);
}
/**
* @group DBAL-234
* @expectedException \Doctrine\DBAL\Schema\SchemaException
*/
public
function
testThrowsExceptionOnRenamingToAlreadyExistingIndex
()
{
$table
=
new
Table
(
"test"
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addColumn
(
'foo'
,
'integer'
);
$table
->
addIndex
(
array
(
'id'
),
'idx_id'
);
$table
->
addIndex
(
array
(
'foo'
),
'idx_foo'
);
$table
->
renameIndex
(
'idx_id'
,
'idx_foo'
);
}
}
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