mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-04 06:37:55 +08:00
Fixes #12735: Fixed yii\console\controllers\MigrateController creating multiple primary keys for field bigPrimaryKey:unsigned
This commit is contained in:
@ -10,6 +10,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #9796: Initialization of not existing `yii\grid\ActionColumn` default buttons (arogachev)
|
||||
- Bug #12681: Changed `data` column type from `text` to `blob` to handle null-byte (`\0`) in serialized RBAC rule properly (silverfire)
|
||||
- Bug #12714: Fixed `yii\validation\EmailValidator` to prevent false-positives checks when property `checkDns` is set to `true` (silverfire)
|
||||
- Bug #12735: Fixed `yii\console\controllers\MigrateController` creating multiple primary keys for field `bigPrimaryKey:unsigned` (SG5)
|
||||
- Bug #12791: Fixed `yii\behaviors\AttributeTypecastBehavior` unable to automatically detect `attributeTypes`, triggering PHP Fatal Error (klimov-paul)
|
||||
- Bug #12803, #12921: Fixed BC break in `yii.activeForm.js` introduced in #11999. Reverted commit 3ba72da (silverfire)
|
||||
- Bug #12810: Fixed `yii\rbac\DbManager::getChildRoles()` and `yii\rbac\PhpManager::getChildRoles()` throws an exception when role has no child roles (mysterydragon)
|
||||
|
||||
@ -462,7 +462,7 @@ class MigrateController extends BaseMigrateController
|
||||
protected function addDefaultPrimaryKey(&$fields)
|
||||
{
|
||||
foreach ($fields as $field) {
|
||||
if ($field['decorators'] === 'primaryKey()' || $field['decorators'] === 'bigPrimaryKey()') {
|
||||
if (false !== strripos($field['decorators'], 'primarykey()')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
32
tests/data/console/migrate_create/create_unsigned_big_pk.php
Normal file
32
tests/data/console/migrate_create/create_unsigned_big_pk.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
return <<<CODE
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{table}`.
|
||||
*/
|
||||
class {$class} extends Migration
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
\$this->createTable('{table}', [
|
||||
'brand_id' => \$this->bigPrimaryKey()->unsigned(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
\$this->dropTable('{table}');
|
||||
}
|
||||
}
|
||||
|
||||
CODE;
|
||||
32
tests/data/console/migrate_create/create_unsigned_pk.php
Normal file
32
tests/data/console/migrate_create/create_unsigned_pk.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
return <<<CODE
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles the creation of table `{table}`.
|
||||
*/
|
||||
class {$class} extends Migration
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
\$this->createTable('{table}', [
|
||||
'brand_id' => \$this->primaryKey()->unsigned(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
\$this->dropTable('{table}');
|
||||
}
|
||||
}
|
||||
|
||||
CODE;
|
||||
@ -95,6 +95,14 @@ class MigrateControllerTest extends TestCase
|
||||
'fields' => 'title:primaryKey,body:text:notNull,price:money(11,2)',
|
||||
]);
|
||||
|
||||
$this->assertCommandCreatedFile('create_unsigned_pk', $migrationName, $table, [
|
||||
'fields' => 'brand_id:primaryKey:unsigned',
|
||||
]);
|
||||
|
||||
$this->assertCommandCreatedFile('create_unsigned_big_pk', $migrationName, $table, [
|
||||
'fields' => 'brand_id:bigPrimaryKey:unsigned',
|
||||
]);
|
||||
|
||||
$this->assertCommandCreatedFile('create_id_pk', $migrationName, $table, [
|
||||
'fields' => 'id:primaryKey,
|
||||
address:string,
|
||||
|
||||
Reference in New Issue
Block a user