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
c8835edf
Commit
c8835edf
authored
Feb 13, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-224] Add API to drop index and pk from tables instances
parent
468af759
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
+56
-0
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+26
-0
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+30
-0
No files found.
lib/Doctrine/DBAL/Schema/Table.php
View file @
c8835edf
...
...
@@ -159,6 +159,32 @@ class Table extends AbstractAsset
return
$this
->
_createIndex
(
$columnNames
,
$indexName
,
false
,
false
);
}
/**
* Drop an index from this table.
*
* @param string $indexName
* @return void
*/
public
function
dropPrimaryKey
()
{
$this
->
dropIndex
(
$this
->
_primaryKeyName
);
}
/**
* Drop an index from this table.
*
* @param string $indexName
* @return void
*/
public
function
dropIndex
(
$indexName
)
{
$indexName
=
strtolower
(
$indexName
);
if
(
!
$this
->
hasIndex
(
$indexName
))
{
throw
SchemaException
::
indexDoesNotExist
(
$indexName
,
$this
->
_name
);
}
unset
(
$this
->
_indexes
[
$indexName
]);
}
/**
*
* @param array $columnNames
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
c8835edf
...
...
@@ -497,4 +497,34 @@ class TableTest extends \Doctrine\Tests\DbalTestCase
$this
->
assertEquals
(
'test.test'
,
$table
->
getFullQualifiedName
(
"test"
));
$this
->
assertEquals
(
'other.test'
,
$table
->
getFullQualifiedName
(
"other"
));
}
/**
* @group DBAL-224
*/
public
function
testDropIndex
()
{
$table
=
new
Table
(
"test"
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addIndex
(
array
(
'id'
),
'idx'
);
$this
->
assertTrue
(
$table
->
hasIndex
(
'idx'
));
$table
->
dropIndex
(
'idx'
);
$this
->
assertFalse
(
$table
->
hasIndex
(
'idx'
));
}
/**
* @group DBAL-224
*/
public
function
testDropPrimaryKey
()
{
$table
=
new
Table
(
"test"
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
setPrimaryKey
(
array
(
'id'
));
$this
->
assertTrue
(
$table
->
hasPrimaryKey
());
$table
->
dropPrimaryKey
();
$this
->
assertFalse
(
$table
->
hasPrimaryKey
());
}
}
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