Skip to content

Commit

Permalink
Fix for when trying to use "Console/cake schema generate snapshot" co…
Browse files Browse the repository at this point in the history
…mmand, line 67 was making the name param snapshot, also fixed auto numbering in the case where the filename wasn't "schema"
  • Loading branch information
bigclick committed Nov 21, 2011
1 parent de5a4ea commit 7a68f7f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Cake/Console/Command/SchemaShell.php
Expand Up @@ -64,7 +64,7 @@ public function startup() {
$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];
}

Expand Down Expand Up @@ -158,18 +158,19 @@ public function generate() {
Configure::write('Cache.disable', $cacheDisable);

if ($snapshot === true) {
$fileName = rtrim($this->params['file'], '.php');
$Folder = new Folder($this->Schema->path);
$result = $Folder->read();

$numToUse = false;
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('/'.$fileName.'(?:[_\d]*)?\.php$/', $file)) {
$count++;
}
}
Expand All @@ -180,8 +181,7 @@ public function generate() {
$count = $numToUse;
}
}

$fileName = rtrim($this->params['file'], '.php');

$content['file'] = $fileName . '_' . $count . '.php';
}

Expand Down Expand Up @@ -530,4 +530,4 @@ public function getOptionParser() {
));
return $parser;
}
}
}

0 comments on commit 7a68f7f

Please sign in to comment.