added createConstraint()/dropConstraing() support to migrations
This commit is contained in:
parent
37cec1d690
commit
abde67f73c
@ -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']);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user