public function parse($definition, \Concrete\Core\Database\Connection $db)
 {
     $schema = new \Doctrine\DBAL\Schema\Schema();
     foreach ($definition as $tableName => $details) {
         if ($db->tableExists($tableName)) {
             continue;
         }
         $table = $schema->createTable($tableName);
         $table = $this->addColumns($table, $details['columns']);
         $table->setPrimaryKey($details['primary']);
     }
     return $schema;
 }
Esempio n. 2
0
 /**
  * Transforms the XML from Adodb XML into
  * Doctrine DBAL Schema
  */
 public function parse(\Concrete\Core\Database\Connection $db)
 {
     $x = $this->rawXML;
     $schema = new \Doctrine\DBAL\Schema\Schema();
     foreach ($x->table as $t) {
         if ($this->ignoreExistingTables && $db->tableExists($t['name'])) {
             continue;
         }
         $table = $schema->createTable((string) $t['name']);
         foreach ($t->field as $f) {
             $options = $this->_getColumnOptions($db, $f);
             $version = isset($options['version']) && $options['version'] ? true : false;
             unset($options['version']);
             $field = $table->addColumn((string) $f['name'], $this->_getColumnType($f), $options);
             if ($version) {
                 $field->setPlatformOption('version', true);
             }
         }
         $this->_setPrimaryKeys($db, $t, $table);
         $this->_setIndexes($db, $t, $table);
         $this->_setTableOpts($db, $t, $table);
     }
     return $schema;
 }