Skip to content

Commit

Permalink
Forcing ModelTask to always reload schema for models when baking. Als…
Browse files Browse the repository at this point in the history
…o setting the dbo's cacheSources = false so table listings are always fresh as well.
  • Loading branch information
markstory committed Dec 30, 2009
1 parent 49e9550 commit ec88bd9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cake/console/libs/tasks/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function __interactive() {

if (in_array($useTable, $this->__tables)) {
$tempModel = new Model(array('name' => $currentModelName, 'table' => $useTable, 'ds' => $this->connection));
$fields = $tempModel->schema();
$fields = $tempModel->schema(true);
if (!array_key_exists('id', $fields)) {
$primaryKey = $this->findPrimaryKey($fields);
}
Expand Down Expand Up @@ -447,7 +447,7 @@ function doAssociations(&$model) {
$this->out(__('One moment while the associations are detected.', true));
}

$fields = $model->schema();
$fields = $model->schema(true);
if (empty($fields)) {
return false;
}
Expand Down Expand Up @@ -487,7 +487,7 @@ function doAssociations(&$model) {
* @return array $associations with belongsTo added in.
*/
function findBelongsTo(&$model, $associations) {
$fields = $model->schema();
$fields = $model->schema(true);
foreach ($fields as $fieldName => $field) {
$offset = strpos($fieldName, '_id');
if ($fieldName != $model->primaryKey && $fieldName != 'parent_id' && $offset !== false) {
Expand Down Expand Up @@ -562,7 +562,7 @@ function findHasAndBelongsToMany(&$model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->__tables as $otherTable) {
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
$modelFieldsTemp = $tempOtherModel->schema();
$modelFieldsTemp = $tempOtherModel->schema(true);

$offset = strpos($otherTable, $model->table . '_');
$otherOffset = strpos($otherTable, '_' . $model->table);
Expand Down Expand Up @@ -695,7 +695,7 @@ function _generatePossibleKeys() {
$possible = array();
foreach ($this->__tables as $otherTable) {
$tempOtherModel = & new Model(array('table' => $otherTable, 'ds' => $this->connection));
$modelFieldsTemp = $tempOtherModel->schema();
$modelFieldsTemp = $tempOtherModel->schema(true);
foreach ($modelFieldsTemp as $fieldName => $field) {
if ($field['type'] == 'integer' || $field['type'] == 'string') {
$possible[$otherTable][] = $fieldName;
Expand Down Expand Up @@ -821,6 +821,7 @@ function getAllTables($useDbConfig = null) {

$tables = array();
$db =& ConnectionManager::getDataSource($useDbConfig);
$db->cacheSources = false;
$usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix'];
if ($usePrefix) {
foreach ($db->listSources() as $table) {
Expand Down

0 comments on commit ec88bd9

Please sign in to comment.