Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions alloy/Plugin/Spot/lib/Spot/Adapter/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,24 @@ public function migrateSyntaxFieldCreate($fieldName, array $fieldInfo)
if(!isset($this->_fieldTypeMap[$fieldInfo['type']])) {
throw new \Spot\Exception("Field type '" . $fieldInfo['type'] . "' not supported");
}

//MOD 20120611 mwoc: only overwrite NULL values with defaults
foreach($fieldInfo as $key => $opt){
if(is_null($opt)){
$fieldInfo[$key] = isset($this->_fieldTypeMap[$fieldInfo['type']][$key]) ? $this->_fieldTypeMap[$fieldInfo['type']][$key] : NULL;
}
}

//Ensure this class will choose adapter type
unset($fieldInfo['adapter_type']);

$fieldInfo = array_merge($this->_fieldTypeMap[$fieldInfo['type']],$fieldInfo);
$fieldInfo['adapter_type'] = $this->_fieldTypeMap[$fieldInfo['type']]['adapter_type'];

$syntax = "`" . $fieldName . "` " . $fieldInfo['adapter_type'];
// Column type and length
$syntax .= is_int($fieldInfo['length']) ? '(' . $fieldInfo['length'] . ')' : '';
// Unsigned
$syntax .= ($fieldInfo['unsigned']) ? ' unsigned' : '';
// Collate
$syntax .= ($fieldInfo['type'] == 'string' || $fieldInfo['type'] == 'text') ? ' COLLATE ' . $this->_collate : '';
$syntax .= ($fieldInfo['type'] == 'email' || $fieldInfo['type'] == 'string' || $fieldInfo['type'] == 'text') ? ' CHARACTER SET '. $this->_charset .' COLLATE ' . $this->_collate : '';
// Nullable
$isNullable = true;
if($fieldInfo['required'] || !$fieldInfo['null']) {
Expand Down Expand Up @@ -230,7 +236,7 @@ public function migrateSyntaxTableCreate($table, array $formattedFields, array $
// Ensure table type is MyISAM if FULLTEXT columns have been specified
if('myisam' !== strtolower($options['engine'])) {
$options['engine'] = 'MyISAM';
}
}
$syntax .= "\n, FULLTEXT(`" . implode('`, `', $fulltextFields) . "`)";
}

Expand Down Expand Up @@ -292,7 +298,7 @@ public function migrateSyntaxTableUpdate($table, array $formattedFields, array $

// Columns
$syntax .= implode(",\n", $columnsSyntax);

// Keys...
$ki = 0;
$tableKeys = array(
Expand Down Expand Up @@ -339,10 +345,10 @@ public function migrateSyntaxTableUpdate($table, array $formattedFields, array $
// Ensure table type is MyISAM if FULLTEXT columns have been specified
if('myisam' !== strtolower($options['engine'])) {
$options['engine'] = 'MyISAM';
}
}
$syntax .= "\n, FULLTEXT(`" . implode('`, `', $fulltextFields) . "`)";
}

// PRIMARY
if($tableKeys['primary']) {
$syntax .= "\n, PRIMARY KEY(`" . implode('`, `', $tableKeys['primary']) . "`)";
Expand Down
Loading