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
abde67f7
Commit
abde67f7
authored
Oct 16, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added createConstraint()/dropConstraing() support to migrations
parent
37cec1d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
9 deletions
+57
-9
Migration.php
lib/Doctrine/Migration.php
+39
-9
Process.php
lib/Doctrine/Migration/Process.php
+18
-0
No files found.
lib/Doctrine/Migration.php
View file @
abde67f7
...
...
@@ -33,15 +33,17 @@
*/
class
Doctrine_Migration
{
protected
$changes
=
array
(
'created_tables'
=>
array
(),
'dropped_tables'
=>
array
(),
'renamed_tables'
=>
array
(),
'added_columns'
=>
array
(),
'renamed_columns'
=>
array
(),
'changed_columns'
=>
array
(),
'removed_columns'
=>
array
(),
'added_indexes'
=>
array
(),
'removed_indexes'
=>
array
()),
protected
$changes
=
array
(
'created_tables'
=>
array
(),
'dropped_tables'
=>
array
(),
'renamed_tables'
=>
array
(),
'added_columns'
=>
array
(),
'renamed_columns'
=>
array
(),
'changed_columns'
=>
array
(),
'removed_columns'
=>
array
(),
'added_indexes'
=>
array
(),
'removed_indexes'
=>
array
(),
'created_constraints'
=>
array
(),
'dropped_constraints'
=>
array
()),
$migrationTableName
=
'migration_version'
,
$migrationClassesDirectory
=
array
(),
$migrationClasses
=
array
();
...
...
@@ -394,6 +396,34 @@ class Doctrine_Migration
$this
->
addChange
(
'renamed_tables'
,
$options
);
}
/**
* createConstraint
*
* @param string $tableName
* @param string $constraintName
* @return void
*/
public
function
createConstraint
(
$tableName
,
$constraintName
,
array
$definition
)
{
$options
=
get_defined_vars
();
$this
->
addChange
(
'created_constraints'
,
$options
);
}
/**
* createConstraint
*
* @param string $tableName
* @param string $constraintName
* @return void
*/
public
function
dropConstraint
(
$tableName
,
$constraintName
,
$primary
)
{
$options
=
get_defined_vars
();
$this
->
addChange
(
'dropped_constraints'
,
$options
);
}
/**
* addColumn
*
...
...
lib/Doctrine/Migration/Process.php
View file @
abde67f7
...
...
@@ -124,4 +124,22 @@ class Doctrine_Migration_Process
$conn
->
export
->
dropIndex
(
$index
[
'tableName'
],
$index
[
'indexName'
]);
}
}
public
function
processCreatedConstraints
(
$constraints
)
{
foreach
(
$constraints
as
$constraint
)
{
$conn
=
$this
->
getConnection
(
$constraint
[
'tableName'
]);
$conn
->
export
->
createConstraint
(
$constraint
[
'tableName'
],
$constraint
[
'constraintName'
],
$constraint
[
'definition'
]);
}
}
public
function
processDroppedConstraints
(
$constraints
)
{
foreach
(
$constraints
as
$constraint
)
{
$conn
=
$this
->
getConnection
(
$constraint
[
'tableName'
]);
$conn
->
export
->
dropConstraint
(
$constraint
[
'tableName'
],
$constraint
[
'constraintName'
],
$constraint
[
'primary'
]);
}
}
}
\ No newline at end of file
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