Commit 4fb5f7c2 authored by romanb's avatar romanb

added createForeignKey() support to export module and migrations

parent abde67f7
......@@ -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']);
}
}
}
\ 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