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
f1c6657c
Commit
f1c6657c
authored
Oct 19, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
introduced dropForeignKey() to Export and Migration
parent
9679e553
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
7 deletions
+49
-7
Export.php
lib/Doctrine/Export.php
+12
-1
Mysql.php
lib/Doctrine/Export/Mysql.php
+7
-0
Migration.php
lib/Doctrine/Migration.php
+21
-5
Process.php
lib/Doctrine/Migration/Process.php
+8
-0
ExportTestCase.php
tests/ExportTestCase.php
+1
-1
No files found.
lib/Doctrine/Export.php
View file @
f1c6657c
...
@@ -127,9 +127,20 @@ class Doctrine_Export extends Doctrine_Connection_Module
...
@@ -127,9 +127,20 @@ class Doctrine_Export extends Doctrine_Connection_Module
public
function
dropConstraint
(
$table
,
$name
,
$primary
=
false
)
public
function
dropConstraint
(
$table
,
$name
,
$primary
=
false
)
{
{
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
);
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
);
$name
=
$this
->
conn
->
quoteIdentifier
(
$
this
->
conn
->
formatter
->
getIndexName
(
$name
)
);
$name
=
$this
->
conn
->
quoteIdentifier
(
$
name
);
return
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$table
.
' DROP CONSTRAINT '
.
$name
);
return
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$table
.
' DROP CONSTRAINT '
.
$name
);
}
}
/**
* drop existing foreign key
*
* @param string $table name of table that should be used in method
* @param string $name name of the foreign key to be dropped
* @return void
*/
public
function
dropForeignKey
(
$table
,
$name
)
{
return
$this
->
dropConstraint
(
$table
,
$name
);
}
/**
/**
* dropSequenceSql
* dropSequenceSql
* drop existing sequence
* drop existing sequence
...
...
lib/Doctrine/Export/Mysql.php
View file @
f1c6657c
...
@@ -636,4 +636,11 @@ class Doctrine_Export_Mysql extends Doctrine_Export
...
@@ -636,4 +636,11 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
,
true
);
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
,
true
);
return
'DROP TABLE '
.
$table
;
return
'DROP TABLE '
.
$table
;
}
}
public
function
dropForeignKey
(
$table
,
$name
)
{
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
);
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
);
return
$this
->
conn
->
exec
(
'ALTER TABLE '
.
$table
.
' DROP FOREIGN KEY '
.
$name
);
}
}
}
\ No newline at end of file
lib/Doctrine/Migration.php
View file @
f1c6657c
...
@@ -34,17 +34,19 @@
...
@@ -34,17 +34,19 @@
class
Doctrine_Migration
class
Doctrine_Migration
{
{
protected
$changes
=
array
(
'created_tables'
=>
array
(),
protected
$changes
=
array
(
'created_tables'
=>
array
(),
'dropped_tables'
=>
array
(),
'renamed_tables'
=>
array
(),
'renamed_tables'
=>
array
(),
'created_constraints'
=>
array
(),
'dropped_fks'
=>
array
(),
'created_fks'
=>
array
(),
'dropped_constraints'
=>
array
(),
'dropped_tables'
=>
array
(),
'added_columns'
=>
array
(),
'added_columns'
=>
array
(),
'renamed_columns'
=>
array
(),
'renamed_columns'
=>
array
(),
'changed_columns'
=>
array
(),
'changed_columns'
=>
array
(),
'removed_columns'
=>
array
(),
'removed_columns'
=>
array
(),
'added_indexes'
=>
array
(),
'added_indexes'
=>
array
(),
'removed_indexes'
=>
array
(),
'removed_indexes'
=>
array
()
'created_constraints'
=>
array
(),
),
'dropped_constraints'
=>
array
(),
'created_fks'
=>
array
()),
$migrationTableName
=
'migration_version'
,
$migrationTableName
=
'migration_version'
,
$migrationClassesDirectory
=
array
(),
$migrationClassesDirectory
=
array
(),
$migrationClasses
=
array
();
$migrationClasses
=
array
();
...
@@ -439,6 +441,20 @@ class Doctrine_Migration
...
@@ -439,6 +441,20 @@ class Doctrine_Migration
$this
->
addChange
(
'created_fks'
,
$options
);
$this
->
addChange
(
'created_fks'
,
$options
);
}
}
/**
* dropForeignKey
*
* @param string $tableName
* @param string $constraintName
* @return void
*/
public
function
dropForeignKey
(
$tableName
,
$fkName
)
{
$options
=
get_defined_vars
();
$this
->
addChange
(
'dropped_fks'
,
$options
);
}
/**
/**
* addColumn
* addColumn
*
*
...
...
lib/Doctrine/Migration/Process.php
View file @
f1c6657c
...
@@ -150,4 +150,12 @@ class Doctrine_Migration_Process
...
@@ -150,4 +150,12 @@ class Doctrine_Migration_Process
$conn
->
export
->
createForeignKey
(
$fk
[
'tableName'
],
$fk
[
'definition'
]);
$conn
->
export
->
createForeignKey
(
$fk
[
'tableName'
],
$fk
[
'definition'
]);
}
}
}
}
public
function
processDroppedFks
(
$foreignKeys
)
{
foreach
(
$foreignKeys
as
$fk
)
{
$conn
=
$this
->
getConnection
(
$fk
[
'tableName'
]);
$conn
->
export
->
dropForeignKey
(
$fk
[
'tableName'
],
$fk
[
'fkName'
]);
}
}
}
}
\ No newline at end of file
tests/ExportTestCase.php
View file @
f1c6657c
...
@@ -56,7 +56,7 @@ class Doctrine_Export_TestCase extends Doctrine_UnitTestCase
...
@@ -56,7 +56,7 @@ class Doctrine_Export_TestCase extends Doctrine_UnitTestCase
{
{
$this
->
export
->
dropConstraint
(
'sometable'
,
'relevancy'
);
$this
->
export
->
dropConstraint
(
'sometable'
,
'relevancy'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER TABLE sometable DROP CONSTRAINT relevancy
_idx
'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER TABLE sometable DROP CONSTRAINT relevancy'
);
}
}
public
function
testCreateIndexExecutesSql
()
public
function
testCreateIndexExecutesSql
()
{
{
...
...
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