mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 14:28:27 +08:00
Fix #18303: Fix creating migration issue for column methods used after defaultValues
This commit is contained in:
@ -7,6 +7,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #18290: Fix response with non-seekable streams (schmunk42)
|
- Bug #18290: Fix response with non-seekable streams (schmunk42)
|
||||||
- Bug #16418: Fixed `yii\data\Pagination::getLinks()` to return links to the first and the last pages regardless of the current page (ptz-nerf, bizley)
|
- Bug #16418: Fixed `yii\data\Pagination::getLinks()` to return links to the first and the last pages regardless of the current page (ptz-nerf, bizley)
|
||||||
- Bug #18297: Replace usage of deprecated `ReflectionParameter::isArray()` method in PHP8 (baletskyi)
|
- Bug #18297: Replace usage of deprecated `ReflectionParameter::isArray()` method in PHP8 (baletskyi)
|
||||||
|
- Bug #18303: Fix creating migration issue for column methods used after defaultValues (wsaid)
|
||||||
- Bug #18287: Fix for OUTPUT INSERTED and computed columns. Added flag to computed values in table schema (darkdef)
|
- Bug #18287: Fix for OUTPUT INSERTED and computed columns. Added flag to computed values in table schema (darkdef)
|
||||||
- Bug #18308: Fixed `\yii\base\Model::getErrorSummary()` reverse order (DrDeath72)
|
- Bug #18308: Fixed `\yii\base\Model::getErrorSummary()` reverse order (DrDeath72)
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ class MigrateController extends BaseMigrateController
|
|||||||
protected function splitFieldIntoChunks($field)
|
protected function splitFieldIntoChunks($field)
|
||||||
{
|
{
|
||||||
$hasDoubleQuotes = false;
|
$hasDoubleQuotes = false;
|
||||||
preg_match_all('/defaultValue\(.*?:.*?\)/', $field, $matches);
|
preg_match_all('/defaultValue\(["\'].*?:?.*?["\']\)/', $field, $matches, PREG_SET_ORDER, 0);
|
||||||
if (isset($matches[0][0])) {
|
if (isset($matches[0][0])) {
|
||||||
$hasDoubleQuotes = true;
|
$hasDoubleQuotes = true;
|
||||||
$originalDefaultValue = $matches[0][0];
|
$originalDefaultValue = $matches[0][0];
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
return <<<CODE
|
||||||
|
<?php
|
||||||
|
|
||||||
|
{$namespace}use yii\db\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the creation of table `{{%test}}`.
|
||||||
|
*/
|
||||||
|
class {$class} extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
\$this->createTable('{{%test}}', [
|
||||||
|
'id' => \$this->primaryKey(),
|
||||||
|
'title' => \$this->string(10)->notNull()->unique()->defaultValue("test")->after("id"),
|
||||||
|
'body' => \$this->text()->notNull()->defaultValue("test")->after("title"),
|
||||||
|
'address' => \$this->text()->notNull()->defaultValue("test")->after("body"),
|
||||||
|
'address2' => \$this->text()->notNull()->defaultValue('te:st')->after("address"),
|
||||||
|
'address3' => \$this->text()->notNull()->defaultValue(':te:st:')->after("address2"),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
\$this->dropTable('{{%test}}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CODE;
|
@ -131,6 +131,14 @@ class MigrateControllerTest extends TestCase
|
|||||||
price:money(11,2):notNull,
|
price:money(11,2):notNull,
|
||||||
parenthesis_in_comment:string(255):notNull:comment(\'Name of set (RU)\')',
|
parenthesis_in_comment:string(255):notNull:comment(\'Name of set (RU)\')',
|
||||||
],
|
],
|
||||||
|
'create_fields_with_col_method_after_default_value' => [
|
||||||
|
'fields' => 'id:primaryKey,
|
||||||
|
title:string(10):notNull:unique:defaultValue("test"):after("id"),
|
||||||
|
body:text:notNull:defaultValue("test"):after("title"),
|
||||||
|
address:text:notNull:defaultValue("test"):after("body"),
|
||||||
|
address2:text:notNull:defaultValue(\'te:st\'):after("address"),
|
||||||
|
address3:text:notNull:defaultValue(\':te:st:\'):after("address2")',
|
||||||
|
],
|
||||||
'create_title_pk' => [
|
'create_title_pk' => [
|
||||||
'fields' => 'title:primaryKey,body:text:notNull,price:money(11,2)',
|
'fields' => 'title:primaryKey,body:text:notNull,price:money(11,2)',
|
||||||
],
|
],
|
||||||
@ -236,6 +244,9 @@ class MigrateControllerTest extends TestCase
|
|||||||
['create_title_with_comma_default_values', 'create_test_table', 'test', $params['create_title_with_comma_default_values']],
|
['create_title_with_comma_default_values', 'create_test_table', 'test', $params['create_title_with_comma_default_values']],
|
||||||
['create_field_with_colon_default_values', 'create_test_table', 'test', $params['create_field_with_colon_default_values']],
|
['create_field_with_colon_default_values', 'create_test_table', 'test', $params['create_field_with_colon_default_values']],
|
||||||
|
|
||||||
|
// @see https://github.com/yiisoft/yii2/issues/18303
|
||||||
|
['create_fields_with_col_method_after_default_value', 'create_test_table', 'test', $params['create_fields_with_col_method_after_default_value']],
|
||||||
|
|
||||||
['drop_test', 'drop_test_table', 'test', []],
|
['drop_test', 'drop_test_table', 'test', []],
|
||||||
['drop_test', 'drop_test__table', 'test_', []],
|
['drop_test', 'drop_test__table', 'test_', []],
|
||||||
['drop_test', 'drop_TEST_table', 'TEST', []],
|
['drop_test', 'drop_TEST_table', 'TEST', []],
|
||||||
|
Reference in New Issue
Block a user