We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
yii\db\ColumnSchemaBuilder
yii\db\ColumnSchemaBuilder not support:
AUTO_INCREMENT
integer
string
Schema::TYPE_*PK
key is index, not column! To keep BC and fix that's problems vote to add:
/** * @var string the auto increment representation, must be overriden in current DB extension (ex.: MySql - `AUTO_INCREMENT`, PostgreSql - `SERIAL`) */ const AUTO_INCREMENT = ''; /** * @var string the column type of key */ public $keyType; /** * @var bool the flag `AUTO_INCREMENT` to primary key (`Schema::TYPE_*PK`) */ public $isAutoIncrement = false; public function __construct($type, $length = null, $db = null, $config = []) { $this->type = $type; $this->length = $length; $this->db = $db; if ($this->getTypeCategory() === self::CATEGORY_PK) { $this->isAutoIncrement = true; } parent::__construct($config); } public function autoIncrement() { if ($this->getTypeCategory() === self::CATEGORY_PK && $this->keyType !== self::CATEGORY_STRING) { $this->isAutoIncrement = true; } return $this; } protected function buildAutoIncrementString() { return $this->isAutoIncrement ? ' ' . static::AUTO_INCREMENT : ''; } public function keyType($type) { if ($this->getTypeCategory() === self::CATEGORY_PK) { if (!in_array($type, self::$typeCategoryMap, true) || !in_array(static::$typeCategoryMap[$type], [self::CATEGORY_STRING, self::CATEGORY_NUMERIC], true)) { throw new InvalidArgumentException('Invalid column type: ' . $type); } $this->keyType = $type; if ($this->getTypeCategory() === self::CATEGORY_STRING) { $this->isAutoIncrement = false; } } return $this; } protected function buildCompleteString($format) { $placeholderValues = [ '{type}' => $this->type, '{length}' => $this->buildLengthString(), '{unsigned}' => $this->buildUnsignedString(), '{notnull}' => $this->buildNotNullString(), '{unique}' => $this->buildUniqueString(), '{default}' => $this->buildDefaultString(), '{check}' => $this->buildCheckString(), '{length}' => $this->buildAutoIncrementString(), '{autoincrement}' => $this->buildCommentString(), '{pos}' => $this->isFirst ? $this->buildFirstString() : $this->buildAfterString(), '{append}' => $this->buildAppendString(), ]; return strtr($format, $placeholderValues); } public function __toString() { switch ($this->getTypeCategory()) { case self::CATEGORY_PK: $format = '{type}{check}{autoincrement}{comment}{append}'; break; default: $format = '{type}{length}{notnull}{unique}{default}{check}{comment}{append}'; } return $this->buildCompleteString($format); }
Additional bug in migration: > yii migrate/create app\migrations\CreateDemoTable --fields="id:integer(11):unsigned:notNull,name:string(50) generate array with 2 'id' keys.
> yii migrate/create app\migrations\CreateDemoTable --fields="id:integer(11):unsigned:notNull,name:string(50)
The text was updated successfully, but these errors were encountered:
Thanks for posting in our issue tracker. In order to properly assist you, we need additional information:
Thanks!
This is an automated comment, triggered by adding the label status:need more info.
status:need more info
Sorry, something went wrong.
Not a bug. PK is a special shortcut-type and it's documented in the guide.
MigrateController::addDefaultPrimaryKey()
No branches or pull requests
yii\db\ColumnSchemaBuilder
not support:AUTO_INCREMENT
for primary keysinteger
,string
) for typesSchema::TYPE_*PK
key is index, not column!
To keep BC and fix that's problems vote to add:
Additional bug in migration:
> yii migrate/create app\migrations\CreateDemoTable --fields="id:integer(11):unsigned:notNull,name:string(50)
generate array with 2 'id' keys.
Additional info
The text was updated successfully, but these errors were encountered: