Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unsigned column #12

Merged
merged 1 commit into from Apr 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion classes/Drivers/Mysql.php
Expand Up @@ -129,6 +129,7 @@ protected function compile_column($field_name, $params, $allow_order = FALSE)
$params = (array) $params;
$null = TRUE;
$auto = FALSE;
$unsigned = FALSE;

foreach ($params as $key => $param)
{
Expand All @@ -154,6 +155,7 @@ protected function compile_column($field_name, $params, $allow_order = FALSE)
}
break;
case 'auto': $auto = (bool) $param; break;
case 'unsigned': $unsigned = $param; break;
default: throw new Kohana_Exception('migrations.bad_column :key', array(':key' => $key));
}
continue; // next iteration
Expand Down Expand Up @@ -191,6 +193,9 @@ protected function compile_column($field_name, $params, $allow_order = FALSE)

$sql = " `$field_name` $type ";

if ($unsigned) {
$sql .= ' UNSIGNED ';
}
isset($default) and $sql .= " $default ";
$sql .= $null ? ' NULL ' : ' NOT NULL ';
$sql .= $auto ? ' AUTO_INCREMENT ' : '';
Expand Down Expand Up @@ -293,4 +298,4 @@ protected function migration_type($native)

return $native . "[$limit]";
}
}
}