1
0
mirror of synced 2025-01-30 20:11:49 +03:00

added createForeignKey() support to export module and migrations

This commit is contained in:
romanb 2007-10-16 17:05:52 +00:00
parent abde67f73c
commit 4fb5f7c201
3 changed files with 37 additions and 3 deletions

View File

@ -442,7 +442,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
$query .= ' (' . implode(', ', $fields) . ')'; $query .= ' (' . implode(', ', $fields) . ')';
return $query; return $query;
} }
/** /**
* createForeignKeySql * createForeignKeySql
* *
@ -458,6 +458,17 @@ class Doctrine_Export extends Doctrine_Connection_Module
return $query; 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 * alter an existing table
* (this method is implemented by the drivers) * (this method is implemented by the drivers)

View File

@ -43,7 +43,8 @@ class Doctrine_Migration
'added_indexes' => array(), 'added_indexes' => array(),
'removed_indexes' => array(), 'removed_indexes' => array(),
'created_constraints' => array(), 'created_constraints' => array(),
'dropped_constraints' => array()), 'dropped_constraints' => array(),
'created_fks' => array()),
$migrationTableName = 'migration_version', $migrationTableName = 'migration_version',
$migrationClassesDirectory = array(), $migrationClassesDirectory = array(),
$migrationClasses = array(); $migrationClasses = array();
@ -411,7 +412,7 @@ class Doctrine_Migration
} }
/** /**
* createConstraint * dropConstraint
* *
* @param string $tableName * @param string $tableName
* @param string $constraintName * @param string $constraintName
@ -424,6 +425,20 @@ class Doctrine_Migration
$this->addChange('dropped_constraints', $options); $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 * addColumn
* *

View File

@ -142,4 +142,12 @@ class Doctrine_Migration_Process
$constraint['primary']); $constraint['primary']);
} }
} }
public function processCreatedFks($foreignKeys)
{
foreach ($foreignKeys as $fk) {
$conn = $this->getConnection($fk['tableName']);
$conn->export->createForeignKey($fk['tableName'], $fk['definition']);
}
}
} }