Skip to content

Commit

Permalink
支持设置默认主键的signed参数
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed May 8, 2019
1 parent 0ca9582 commit 46d0e8c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions phinx/src/Phinx/Db/Adapter/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,17 @@ public function createTable(Table $table)

// Add the default primary key
$columns = $table->getPendingColumns();
if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) {
$column = new Column();
$column->setName('id')
->setType('integer')
->setIdentity(true);

array_unshift($columns, $column);
$options['primary_key'] = 'id';
if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) {
$options['id'] = 'id';
}

} elseif (isset($options['id']) && is_string($options['id'])) {
if (isset($options['id']) && is_string($options['id'])) {
// Handle id => "field_name" to support AUTO_INCREMENT
$column = new Column();
$column->setName($options['id'])
->setType('integer')
->setSigned(isset($options['signed']) ? $options['signed'] : true)
->setIdentity(true);

array_unshift($columns, $column);
Expand Down

0 comments on commit 46d0e8c

Please sign in to comment.