Commit abde67f7 authored by romanb's avatar romanb

added createConstraint()/dropConstraing() support to migrations

parent 37cec1d6
......@@ -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
*
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment