Permalink
Browse files

Change array insertion order around so constraints is last.

This makes the generated fixtures look better.
  • Loading branch information...
markstory committed May 28, 2013
1 parent 5b71cdb commit e3357d2c5a610544a7444e97a8b7c23308b9d637
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/Cake/Console/Command/UpgradeShell.php
@@ -352,11 +352,12 @@ protected function _processFixture($content) {
// Process field property.
$processor = function ($matches) use ($export) {
eval('$data = [' . $matches[2] . '];');
$constraints = [];
$out = [];
foreach ($data as $field => $properties) {
// Move 'key' into a constraint
if (isset($properties['key']) && $properties['key'] === 'primary') {
$out['constraints']['primary'] = [
$constraints['primary'] = [
'type' => 'primary',
'columns' => [$field]
];
@@ -373,12 +374,15 @@ protected function _processFixture($content) {
// Move unique indexes over
if (!empty($indexProps['unique'])) {
unset($indexProps['unique']);
$out['constraints'][$index] = ['type' => 'unique'] + $indexProps;
$constraints[$index] = ['type' => 'unique'] + $indexProps;
continue;
}
$out['indexes'][$index] = $indexProps;
}
}
if (count($constraints)) {
$out['constraints'] = $constraints;
}
return $matches[1] . "\n\t\t" . implode(",\n\t\t", $export($out)) . "\n\t" . $matches[3];
};
$content = preg_replace_callback(

0 comments on commit e3357d2

Please sign in to comment.