added createForeignKey() support to export module and migrations
This commit is contained in:
parent
abde67f73c
commit
4fb5f7c201
@ -458,6 +458,17 @@ class Doctrine_Export extends Doctrine_Connection_Module
|
||||
|
||||
return $query;
|
||||
}
|
||||
/**
|
||||
* createForeignKey
|
||||
*
|
||||
* @param string $table name of the table on which the foreign key is to be created
|
||||
* @param array $definition associative array that defines properties of the foreign key to be created.
|
||||
* @return string
|
||||
*/
|
||||
public function createForeignKey($table, array $definition)
|
||||
{
|
||||
return $this->conn->execute($this->createForeignKeySql($table, $definition));
|
||||
}
|
||||
/**
|
||||
* alter an existing table
|
||||
* (this method is implemented by the drivers)
|
||||
|
@ -43,7 +43,8 @@ class Doctrine_Migration
|
||||
'added_indexes' => array(),
|
||||
'removed_indexes' => array(),
|
||||
'created_constraints' => array(),
|
||||
'dropped_constraints' => array()),
|
||||
'dropped_constraints' => array(),
|
||||
'created_fks' => array()),
|
||||
$migrationTableName = 'migration_version',
|
||||
$migrationClassesDirectory = array(),
|
||||
$migrationClasses = array();
|
||||
@ -411,7 +412,7 @@ class Doctrine_Migration
|
||||
}
|
||||
|
||||
/**
|
||||
* createConstraint
|
||||
* dropConstraint
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string $constraintName
|
||||
@ -424,6 +425,20 @@ class Doctrine_Migration
|
||||
$this->addChange('dropped_constraints', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* createForeignKey
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string $constraintName
|
||||
* @return void
|
||||
*/
|
||||
public function createForeignKey($tableName, array $definition)
|
||||
{
|
||||
$options = get_defined_vars();
|
||||
|
||||
$this->addChange('created_fks', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* addColumn
|
||||
*
|
||||
|
@ -142,4 +142,12 @@ class Doctrine_Migration_Process
|
||||
$constraint['primary']);
|
||||
}
|
||||
}
|
||||
|
||||
public function processCreatedFks($foreignKeys)
|
||||
{
|
||||
foreach ($foreignKeys as $fk) {
|
||||
$conn = $this->getConnection($fk['tableName']);
|
||||
$conn->export->createForeignKey($fk['tableName'], $fk['definition']);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user