ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 12366


Ignore:
Timestamp:
Jul 23, 2009, 7:44:23 PM (11 years ago)
Author:
ebihara
Message:

decreased wasted migration scripts

Location:
OpenPNE3/trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/lib/migration/opMigrationDiff.class.php

    r12257 r12366  
    5353    $toInfo = $this->_buildModelInformation($toModels);
    5454
     55    $this->_decreaseInformations($fromInfo, $toInfo);
     56
    5557    // Build array of changes between the from and to information
    5658    $changes = $this->_buildChanges($fromInfo, $toInfo);
     
    6062    return $changes;
    6163  }
     64
     65  protected function _decreaseInformations(&$fromInfo, &$toInfo)
     66  {
     67    $_changes = array_intersect_key($fromInfo, $toInfo);
     68
     69    foreach ($_changes as $tableName => $tableInfo)
     70    {
     71      foreach ($tableInfo['columns'] as $columnName => $columnInfo)
     72      {
     73        if (!empty($fromInfo[$tableName]['columns'][$columnName])
     74            && !empty($toInfo[$tableName]['columns'][$columnName]))
     75        {
     76          $fromColumn =& $fromInfo[$tableName]['columns'][$columnName];
     77          $toColumn =& $toInfo[$tableName]['columns'][$columnName];
     78
     79          if (('integer' === $fromColumn['type'] && '1' == $fromColumn['length'])
     80              || ('integer' === $toColumn['type'] && '1' == $toColumn['length']))
     81          {
     82            $fromColumn['type'] = 'boolean';
     83            $fromColumn['length'] = '1';
     84            $toColumn['type'] = 'boolean';
     85            $toColumn['length'] = '1';
     86          }
     87
     88          $this->_removedSpecifiedEmptyParameter('unsigned', $fromColumn, $toColumn);
     89          $this->_removedSpecifiedEmptyParameter('fixed', $fromColumn, $toColumn);
     90          $this->_removedSpecifiedEmptyParameter('primary', $fromColumn, $toColumn);
     91          $this->_removedSpecifiedEmptyParameter('autoincrement', $fromColumn, $toColumn);
     92          $this->_removedSpecifiedEmptyParameter('notnull', $fromColumn, $toColumn);
     93          $this->_removedSpecifiedEmptyParameter('default', $fromColumn, $toColumn);
     94        }
     95      }
     96    }
     97  }
     98
     99  protected function _removedSpecifiedEmptyParameter($key, &$array1, &$array2)
     100  {
     101    if ((isset($array1[$key]) || isset($array2[$key])) && !(isset($array1[$key]) && isset($array2[$key])))
     102    {
     103      if (empty($array1[$key]) && empty($array2[$key]))
     104      {
     105        $array1[$key] = null;
     106        $array2[$key] = null;
     107        unset($array1[$key], $array2[$key]);
     108      }
     109    }
     110  }
    62111}
  • OpenPNE3/trunk/lib/task/openpneGenerateMigrationsTask.class.php

    r12340 r12366  
    6767        $content = preg_replace('/class [a-zA-Z0-9_]+/', 'class ToPrfx'.Doctrine_Inflector::classify($tableName), $content);
    6868        file_put_contents($modelTmp.'/ToPrfx'.Doctrine_Inflector::classify($tableName).'.class.php', $content);
    69         file_put_contents('/tmp/ubeToPrfx'.Doctrine_Inflector::classify($tableName).'.class.php', $content);
    7069      }
    7170      else
Note: See TracChangeset for help on using the changeset viewer.