Changeset 4310

Show
Ignore:
Timestamp:
04/30/08 17:19:40 (14 months ago)
Author:
jwage
Message:

fixes #986

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Export.php

    r4252 r4310  
    10701070             if ( ! isset($connections[$connectionName])) { 
    10711071                 $connections[$connectionName] = array( 
    1072                      'create_tables' => array(), 
     1072                     'create_tables'    => array(), 
    10731073                     'create_sequences' => array(), 
    1074                      'alters' => array() 
     1074                     'create_indexes'   => array(), 
     1075                     'alters'           => array() 
    10751076                 ); 
    10761077             } 
     
    10811082             // We need these to happen first 
    10821083             foreach ($sql as $key => $query) { 
    1083                  if (strstr($query, 'CREATE TABLE')) { 
     1084                 // If create table statement 
     1085                 if (substr($query, 0, strlen('CREATE TABLE')) == 'CREATE TABLE') { 
    10841086                     $connections[$connectionName]['create_tables'][] = $query; 
    10851087 
    10861088                     unset($sql[$key]); 
     1089                     continue; 
    10871090                 } 
    10881091 
    1089                  if (strstr($query, 'CREATE SEQUENCE')) { 
     1092                 // If create sequence statement 
     1093                 if (substr($query, 0, strlen('CREATE SEQUENCE')) == 'CREATE SEQUENCE') { 
    10901094                     $connections[$connectionName]['create_sequences'][] = $query; 
    10911095 
    10921096                     unset($sql[$key]); 
     1097                     continue; 
     1098                 } 
     1099 
     1100                 // If create index statement 
     1101                 if (preg_grep("/CREATE .* INDEX/", array($query))) { 
     1102                     $connections[$connectionName]['create_indexes'][] =  $query; 
     1103 
     1104                     unset($sql[$key]); 
     1105                     continue; 
     1106                 } 
     1107 
     1108                 // If alter table statement 
     1109                 if (substr($query, 0, strlen('ALTER TABLE')) == 'ALTER TABLE') { 
     1110                     $connections[$connectionName]['alters'][] = $query; 
     1111 
     1112                     unset($sql[$key]); 
     1113                     continue; 
    10931114                 } 
    10941115             } 
    1095  
    1096              $connections[$connectionName]['alters'] = array_merge($connections[$connectionName]['alters'], $sql); 
    10971116         } 
    10981117 
    1099          // Loop over all the sql again to merge the creates and alters in to the same array, but so that the alters are at the bottom 
     1118         // Loop over all the sql again to merge everything together so it is in the correct order 
    11001119         $build = array(); 
    11011120         foreach ($connections as $connectionName => $sql) { 
    1102              $build[$connectionName] = array_merge($sql['create_tables'], $sql['create_sequences'], $sql['alters']); 
     1121             $build[$connectionName] = array_merge($sql['create_tables'], $sql['create_sequences'], $sql['create_indexes'], $sql['alters']); 
    11031122         } 
    11041123