Merge pull request #327 from bigclick/patch-1

Fix for when trying to use "Console/cake schema generate snapshot"
This commit is contained in:
Mark Story 2011-11-21 07:20:07 -08:00
commit 340d112693

View file

@ -64,7 +64,7 @@ class SchemaShell extends Shell {
$name = $path = $connection = $plugin = null;
if (!empty($this->params['name'])) {
$name = $this->params['name'];
} elseif (!empty($this->args[0])) {
} elseif (!empty($this->args[0]) && $this->args[0] !== 'snapshot') {
$name = $this->params['name'] = $this->args[0];
}
@ -158,6 +158,7 @@ class SchemaShell extends Shell {
Configure::write('Cache.disable', $cacheDisable);
if ($snapshot === true) {
$fileName = rtrim($this->params['file'], '.php');
$Folder = new Folder($this->Schema->path);
$result = $Folder->read();
@ -165,11 +166,11 @@ class SchemaShell extends Shell {
if (isset($this->params['snapshot'])) {
$numToUse = $this->params['snapshot'];
}
$count = 0;
if (!empty($result[1])) {
foreach ($result[1] as $file) {
if (preg_match('/schema(?:[_\d]*)?\.php$/', $file)) {
if (preg_match('/'.preg_quote($fileName).'(?:[_\d]*)?\.php$/', $file)) {
$count++;
}
}
@ -180,8 +181,7 @@ class SchemaShell extends Shell {
$count = $numToUse;
}
}
$fileName = rtrim($this->params['file'], '.php');
$content['file'] = $fileName . '_' . $count . '.php';
}
@ -530,4 +530,4 @@ class SchemaShell extends Shell {
));
return $parser;
}
}
}