mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Removed unsignedPrimaryKey()
schema builder type; now, the unsigned()
modifier works with primary key types e.g. pk()->unsigned()
or bigpk()->unsigned()
.
This commit is contained in:
@ -76,8 +76,9 @@ class ColumnSchemaBuilder extends Object
|
||||
*/
|
||||
public $categoryMap = [
|
||||
Schema::TYPE_PK => self::CATEGORY_PK,
|
||||
Schema::TYPE_UPK => self::CATEGORY_PK,
|
||||
Schema::TYPE_BIGPK => self::CATEGORY_PK,
|
||||
Schema::TYPE_UNSIGNEDPK => self::CATEGORY_PK,
|
||||
Schema::TYPE_UBIGPK => self::CATEGORY_PK,
|
||||
Schema::TYPE_CHAR => self::CATEGORY_STRING,
|
||||
Schema::TYPE_STRING => self::CATEGORY_STRING,
|
||||
Schema::TYPE_TEXT => self::CATEGORY_STRING,
|
||||
@ -169,13 +170,11 @@ class ColumnSchemaBuilder extends Object
|
||||
{
|
||||
switch ($this->type) {
|
||||
case Schema::TYPE_PK:
|
||||
$this->type = Schema::TYPE_UNSIGNEDPK;
|
||||
break;
|
||||
$this->type = Schema::TYPE_UPK;
|
||||
return $this;
|
||||
case Schema::TYPE_BIGPK:
|
||||
if (null === $this->length)
|
||||
$this->length = 20;
|
||||
$this->type = Schema::TYPE_UNSIGNEDPK;
|
||||
break;
|
||||
$this->type = Schema::TYPE_UBIGPK;
|
||||
return $this;
|
||||
}
|
||||
$this->isUnsigned = true;
|
||||
return $this;
|
||||
|
@ -41,8 +41,9 @@ abstract class Schema extends Object
|
||||
* The following are the supported abstract column data types.
|
||||
*/
|
||||
const TYPE_PK = 'pk';
|
||||
const TYPE_UPK = 'upk';
|
||||
const TYPE_BIGPK = 'bigpk';
|
||||
const TYPE_UNSIGNEDPK = 'unsignedpk';
|
||||
const TYPE_UBIGPK = 'ubigpk';
|
||||
const TYPE_CHAR = 'char';
|
||||
const TYPE_STRING = 'string';
|
||||
const TYPE_TEXT = 'text';
|
||||
|
@ -63,18 +63,6 @@ trait SchemaBuilderTrait
|
||||
return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BIGPK, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unsigned primary key column.
|
||||
* @param integer $length column size or precision definition.
|
||||
* This parameter will be ignored if not supported by the DBMS.
|
||||
* @return ColumnSchemaBuilder the column instance which can be further customized.
|
||||
* @since 2.0.8
|
||||
*/
|
||||
public function unsignedPrimaryKey($length = null)
|
||||
{
|
||||
return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_UNSIGNEDPK, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a char column.
|
||||
* @param integer $length column size definition i.e. the maximum string length.
|
||||
|
@ -22,8 +22,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
*/
|
||||
public $typeMap = [
|
||||
Schema::TYPE_PK => 'int NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_UPK => 'int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_BIGPK => 'bigint NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_UNSIGNEDPK => 'int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_UBIGPK => 'bigint UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_CHAR => 'char(1)',
|
||||
Schema::TYPE_STRING => 'varchar(255)',
|
||||
Schema::TYPE_TEXT => 'varchar',
|
||||
|
@ -23,8 +23,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
*/
|
||||
public $typeMap = [
|
||||
Schema::TYPE_PK => 'int IDENTITY PRIMARY KEY',
|
||||
Schema::TYPE_UPK => 'int IDENTITY PRIMARY KEY',
|
||||
Schema::TYPE_BIGPK => 'bigint IDENTITY PRIMARY KEY',
|
||||
Schema::TYPE_UNSIGNEDPK => 'int IDENTITY PRIMARY KEY',
|
||||
Schema::TYPE_UBIGPK => 'bigint IDENTITY PRIMARY KEY',
|
||||
Schema::TYPE_CHAR => 'nchar(1)',
|
||||
Schema::TYPE_STRING => 'nvarchar(255)',
|
||||
Schema::TYPE_TEXT => 'ntext',
|
||||
|
@ -24,8 +24,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
*/
|
||||
public $typeMap = [
|
||||
Schema::TYPE_PK => 'int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_UPK => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_BIGPK => 'bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_UNSIGNEDPK => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_UBIGPK => 'bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
Schema::TYPE_CHAR => 'char(1)',
|
||||
Schema::TYPE_STRING => 'varchar(255)',
|
||||
Schema::TYPE_TEXT => 'text',
|
||||
|
@ -25,8 +25,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
*/
|
||||
public $typeMap = [
|
||||
Schema::TYPE_PK => 'NUMBER(10) NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_UPK => 'NUMBER(10) UNSIGNED NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_BIGPK => 'NUMBER(20) NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_UNSIGNEDPK => 'NUMBER(10) UNSIGNED NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_UBIGPK => 'NUMBER(20) UNSIGNED NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_CHAR => 'CHAR(1)',
|
||||
Schema::TYPE_STRING => 'VARCHAR2(255)',
|
||||
Schema::TYPE_TEXT => 'CLOB',
|
||||
|
@ -48,8 +48,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
*/
|
||||
public $typeMap = [
|
||||
Schema::TYPE_PK => 'serial NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_UPK => 'serial NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_BIGPK => 'bigserial NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_UNSIGNEDPK => 'serial NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_UBIGPK => 'bigserial NOT NULL PRIMARY KEY',
|
||||
Schema::TYPE_CHAR => 'char(1)',
|
||||
Schema::TYPE_STRING => 'varchar(255)',
|
||||
Schema::TYPE_TEXT => 'text',
|
||||
|
@ -27,8 +27,9 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
*/
|
||||
public $typeMap = [
|
||||
Schema::TYPE_PK => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL',
|
||||
Schema::TYPE_UPK => 'integer UNSIGNED PRIMARY KEY AUTOINCREMENT NOT NULL',
|
||||
Schema::TYPE_BIGPK => 'bigint PRIMARY KEY AUTOINCREMENT NOT NULL',
|
||||
Schema::TYPE_UNSIGNEDPK => 'integer UNSIGNED PRIMARY KEY AUTOINCREMENT NOT NULL',
|
||||
Schema::TYPE_UBIGPK => 'bigint UNSIGNED PRIMARY KEY AUTOINCREMENT NOT NULL',
|
||||
Schema::TYPE_CHAR => 'char(1)',
|
||||
Schema::TYPE_STRING => 'varchar(255)',
|
||||
Schema::TYPE_TEXT => 'text',
|
||||
|
@ -905,23 +905,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
],
|
||||
],
|
||||
[
|
||||
Schema::TYPE_UNSIGNEDPK . '(20)',
|
||||
$this->unsignedPrimaryKey(20),
|
||||
[
|
||||
'mysql' => 'int(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
'postgres' => 'serial NOT NULL PRIMARY KEY',
|
||||
],
|
||||
],
|
||||
[
|
||||
Schema::TYPE_UNSIGNEDPK,
|
||||
$this->unsignedPrimaryKey(),
|
||||
[
|
||||
'mysql' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
'postgres' => 'serial NOT NULL PRIMARY KEY',
|
||||
],
|
||||
],
|
||||
[
|
||||
Schema::TYPE_UNSIGNEDPK,
|
||||
Schema::TYPE_UPK,
|
||||
$this->primaryKey()->unsigned(),
|
||||
[
|
||||
'mysql' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
@ -929,11 +913,11 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
],
|
||||
],
|
||||
[
|
||||
Schema::TYPE_UNSIGNEDPK,
|
||||
$this->primaryKey(6)->unsigned(),
|
||||
Schema::TYPE_UBIGPK,
|
||||
$this->bigPrimaryKey()->unsigned(),
|
||||
[
|
||||
'mysql' => 'int(6) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
'postgres' => 'serial NOT NULL PRIMARY KEY',
|
||||
'mysql' => 'bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY',
|
||||
'postgres' => 'bigserial NOT NULL PRIMARY KEY',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
Reference in New Issue
Block a user