diff --git a/src/Schema/Column/AbstractColumnSchema.php b/src/Schema/Column/AbstractColumnSchema.php index 8281163a5..a6b4ef8a0 100644 --- a/src/Schema/Column/AbstractColumnSchema.php +++ b/src/Schema/Column/AbstractColumnSchema.php @@ -7,12 +7,14 @@ use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\Constant\PhpType; +use Yiisoft\Db\Constraint\ForeignKeyConstraint; + use function is_array; /** * Represents the metadata of a column in a database table. * - * It provides information about the column's name, type, size, precision, and other details. + * It provides information about the column's type, size, scale, and other details. * * The `ColumnSchema` class is used to store and retrieve metadata about a column in a database table. * @@ -25,10 +27,9 @@ * use Yiisoft\Db\Schema\ColumnSchema; * * $column = (new IntegerColumnSchema()) - * ->name('id') - * ->allowNull(false) - * ->dbType('int(11)') - * ->type('integer') + * ->notNull() + * ->dbType('int') + * ->size(11) * ->defaultValue(0) * ->autoIncrement() * ->primaryKey(); @@ -36,8 +37,8 @@ */ abstract class AbstractColumnSchema implements ColumnSchemaInterface { - private bool $allowNull = false; private bool $autoIncrement = false; + private string|null $check = null; private string|null $comment = null; private bool $computed = false; private string|null $dbType = null; @@ -46,9 +47,11 @@ abstract class AbstractColumnSchema implements ColumnSchemaInterface private string|null $extra = null; private bool $isPrimaryKey = false; private string|null $name = null; - private int|null $precision = null; + private bool $notNull = false; + private ForeignKeyConstraint|null $reference = null; private int|null $scale = null; private int|null $size = null; + private bool $unique = false; private bool $unsigned = false; /** @@ -59,9 +62,12 @@ public function __construct( ) { } + /** + * @deprecated Use {@see notNull()} instead. Will be removed in version 2.0. + */ public function allowNull(bool $allowNull = true): static { - $this->allowNull = $allowNull; + $this->notNull(!$allowNull); return $this; } @@ -71,6 +77,12 @@ public function autoIncrement(bool $autoIncrement = true): static return $this; } + public function check(string|null $check): static + { + $this->check = $check; + return $this; + } + public function comment(string|null $comment): static { $this->comment = $comment; @@ -107,6 +119,11 @@ public function extra(string|null $extra): static return $this; } + public function getCheck(): string|null + { + return $this->check; + } + public function getComment(): string|null { return $this->comment; @@ -132,14 +149,20 @@ public function getExtra(): string|null return $this->extra; } + /** + * @deprecated Will be removed in version 2.0. + */ public function getName(): string|null { return $this->name; } + /** + * @deprecated Use {@see getSize()} instead. Will be removed in version 2.0. + */ public function getPrecision(): int|null { - return $this->precision; + return $this->getSize(); } public function getPhpType(): string @@ -147,6 +170,11 @@ public function getPhpType(): string return PhpType::MIXED; } + public function getReference(): ForeignKeyConstraint|null + { + return $this->reference; + } + public function getScale(): int|null { return $this->scale; @@ -162,9 +190,12 @@ public function getType(): string return $this->type; } + /** + * @deprecated Use {@see isNotNull()} instead. Will be removed in version 2.0. + */ public function isAllowNull(): bool { - return $this->allowNull; + return !$this->isNotNull(); } public function isAutoIncrement(): bool @@ -177,11 +208,21 @@ public function isComputed(): bool return $this->computed; } + public function isNotNull(): bool + { + return $this->notNull; + } + public function isPrimaryKey(): bool { return $this->isPrimaryKey; } + public function isUnique(): bool + { + return $this->unique; + } + public function isUnsigned(): bool { return $this->unsigned; @@ -192,11 +233,13 @@ public function load(array $info): static foreach ($info as $key => $value) { /** * @psalm-suppress PossiblyInvalidCast - * @psalm-suppress RiskyCast + * @psalm-suppress InvalidCast + * @psalm-suppress DeprecatedMethod */ match ($key) { 'allow_null' => $this->allowNull((bool) $value), 'auto_increment' => $this->autoIncrement((bool) $value), + 'check' => $this->check($value !== null ? (string) $value : null), 'comment' => $this->comment($value !== null ? (string) $value : null), 'computed' => $this->computed((bool) $value), 'db_type' => $this->dbType($value !== null ? (string) $value : null), @@ -204,10 +247,13 @@ public function load(array $info): static 'enum_values' => $this->enumValues(is_array($value) ? $value : null), 'extra' => $this->extra($value !== null ? (string) $value : null), 'name' => $this->name($value !== null ? (string) $value : null), + 'not_null' => $this->notNull((bool) $value), 'primary_key' => $this->primaryKey((bool) $value), 'precision' => $this->precision($value !== null ? (int) $value : null), + 'reference' => $this->reference($value instanceof ForeignKeyConstraint ? $value : null), 'scale' => $this->scale($value !== null ? (int) $value : null), 'size' => $this->size($value !== null ? (int) $value : null), + 'unique' => $this->unique((bool) $value), 'unsigned' => $this->unsigned((bool) $value), default => null, }; @@ -216,24 +262,41 @@ public function load(array $info): static return $this; } + /** + * @deprecated Will be removed in version 2.0. + */ public function name(string|null $name): static { $this->name = $name; return $this; } - public function precision(int|null $precision): static + public function notNull(bool $notNull = true): static { - $this->precision = $precision; + $this->notNull = $notNull; return $this; } + /** + * @deprecated Use {@see size()} instead. Will be removed in version 2.0. + */ + public function precision(int|null $precision): static + { + return $this->size($precision); + } + public function primaryKey(bool $isPrimaryKey = true): static { $this->isPrimaryKey = $isPrimaryKey; return $this; } + public function reference(ForeignKeyConstraint|null $reference): static + { + $this->reference = $reference; + return $this; + } + public function scale(int|null $scale): static { $this->scale = $scale; @@ -252,6 +315,12 @@ public function type(string $type): static return $this; } + public function unique(bool $unique = true): static + { + $this->unique = $unique; + return $this; + } + public function unsigned(bool $unsigned = true): static { $this->unsigned = $unsigned; diff --git a/src/Schema/Column/ColumnBuilder.php b/src/Schema/Column/ColumnBuilder.php index 0f89b3f6e..ababbb70d 100644 --- a/src/Schema/Column/ColumnBuilder.php +++ b/src/Schema/Column/ColumnBuilder.php @@ -21,8 +21,7 @@ public static function primaryKey(bool $autoIncrement = true): ColumnSchemaInter { return static::integer() ->primaryKey() - ->autoIncrement($autoIncrement) - ->allowNull(false); + ->autoIncrement($autoIncrement); } /** @@ -32,8 +31,7 @@ public static function smallPrimaryKey(bool $autoIncrement = true): ColumnSchema { return static::smallint() ->primaryKey() - ->autoIncrement($autoIncrement) - ->allowNull(false); + ->autoIncrement($autoIncrement); } /** @@ -43,8 +41,7 @@ public static function bigPrimaryKey(bool $autoIncrement = true): ColumnSchemaIn { return static::bigint() ->primaryKey() - ->autoIncrement($autoIncrement) - ->allowNull(false); + ->autoIncrement($autoIncrement); } /** @@ -54,8 +51,7 @@ public static function uuidPrimaryKey(bool $autoIncrement = false): ColumnSchema { return static::uuid() ->primaryKey() - ->autoIncrement($autoIncrement) - ->allowNull(false); + ->autoIncrement($autoIncrement); } // Abstract type column builders diff --git a/src/Schema/Column/ColumnSchemaInterface.php b/src/Schema/Column/ColumnSchemaInterface.php index 99a743928..9e55230ee 100644 --- a/src/Schema/Column/ColumnSchemaInterface.php +++ b/src/Schema/Column/ColumnSchemaInterface.php @@ -6,14 +6,15 @@ use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\Constant\PhpType; +use Yiisoft\Db\Constraint\ForeignKeyConstraint; /** * This interface defines a set of methods that must be implemented by a class that represents the column schema of a * database table column. * * @psalm-type ColumnInfo = array{ - * allow_null?: bool|string|null, * auto_increment?: bool|string, + * check?: string|null, * comment?: string|null, * computed?: bool|string, * db_type?: string|null, @@ -21,13 +22,14 @@ * enum_values?: array|null, * extra?: string|null, * primary_key?: bool|string, - * name?: string|null, - * precision?: int|string|null, + * not_null?: bool|string, + * reference?: ForeignKeyConstraint|null, * scale?: int|string|null, * schema?: string|null, * size?: int|string|null, * table?: string|null, * type?: ColumnType::*, + * unique?: bool|string, * unsigned?: bool|string, * ... * } @@ -41,9 +43,11 @@ interface ColumnSchemaInterface * * ```php * $columns = [ - * 'description' => $this->text()->allowNull(), + * 'description' => ColumnBuilder::text()->allowNull(), * ]; * ``` + * + * @deprecated Use {@see notNull()} instead. Will be removed in version 2.0. */ public function allowNull(bool $allowNull = true): static; @@ -56,12 +60,23 @@ public function allowNull(bool $allowNull = true): static; * * ```php * $columns = [ - * 'id' => $this->primaryKey()->autoIncrement(), + * 'id' => ColumnBuilder::primaryKey()->autoIncrement(), * ]; * ``` */ public function autoIncrement(bool $autoIncrement = true): static; + /** + * The check constraint for the column to specify an expression that must be true for each row in the table. + * + * ```php + * $columns = [ + * 'age' => ColumnBuilder::integer()->check('age > 0'), + * ]; + * ``` + */ + public function check(string|null $check): static; + /** * The comment for a column in a database table. * @@ -69,7 +84,7 @@ public function autoIncrement(bool $autoIncrement = true): static; * * ```php * $columns = [ - * 'description' => $this->text()->comment('Description of the product'), + * 'description' => ColumnBuilder::text()->comment('Description of the product'), * ]; * ``` */ @@ -82,7 +97,7 @@ public function comment(string|null $comment): static; * * ```php * $columns = [ - * 'description' => $this->text()->computed(true), + * 'full_name' => ColumnBuilder::text()->computed(true), * ]; * ``` */ @@ -97,7 +112,7 @@ public function computed(bool $computed = true): static; * * ```php * $columns = [ - * 'description' => $this->text()->dbType('text'), + * 'description' => ColumnBuilder::text()->dbType('text'), * ]; * ``` */ @@ -120,7 +135,7 @@ public function dbTypecast(mixed $value): mixed; * * ```php * $columns = [ - * 'description' => $this->text()->defaultValue('Description of the product'), + * 'description' => ColumnBuilder::text()->defaultValue('Description of the product'), * ]; * ``` */ @@ -131,7 +146,7 @@ public function defaultValue(mixed $defaultValue): static; * * ```php * $columns = [ - * 'status' => $this->string(16)->enumValues(['active', 'inactive']), + * 'status' => ColumnBuilder::string(16)->enumValues(['active', 'inactive']), * ]; * ``` */ @@ -145,12 +160,19 @@ public function enumValues(array|null $enumValues): static; * * ```php * $columns = [ - * 'description' => $this->text()->extra('ON UPDATE CURRENT_TIMESTAMP'), + * 'updated_at' => ColumnBuilder::integer()->extra('ON UPDATE CURRENT_TIMESTAMP'), * ]; * ``` */ public function extra(string|null $extra): static; + /** + * Returns the check constraint for the column. + * + * @see check() + */ + public function getCheck(): string|null; + /** * @return string|null The comment of the column. * @@ -192,6 +214,8 @@ public function getExtra(): string|null; /** * @return string|null The name of the column. + * + * @deprecated Will be removed in version 2.0. */ public function getName(): string|null; @@ -199,6 +223,8 @@ public function getName(): string|null; * @return int|null The precision of the column. * * @see precision() + * + * @deprecated Use {@see getSize()} instead. Will be removed in version 2.0. */ public function getPrecision(): int|null; @@ -210,6 +236,13 @@ public function getPrecision(): int|null; */ public function getPhpType(): string; + /** + * Returns the reference to the foreign key constraint. + * + * @see reference() + */ + public function getReference(): ForeignKeyConstraint|null; + /** * @return int|null The scale of the column. * @@ -236,6 +269,8 @@ public function getType(): string; * Whether this column is nullable. * * @see allowNull() + * + * @deprecated Use {@see isNotNull()} instead. Will be removed in version 2.0. */ public function isAllowNull(): bool; @@ -255,6 +290,13 @@ public function isAutoIncrement(): bool; */ public function isComputed(): bool; + /** + * Whether this column is not nullable. + * + * @see notNull() + */ + public function isNotNull(): bool; + /** * Whether this column is a part of primary key. * @@ -262,6 +304,13 @@ public function isComputed(): bool; */ public function isPrimaryKey(): bool; + /** + * Whether this column has a unique index. + * + * @see unique() + */ + public function isUnique(): bool; + /** * Whether this column is unsigned. This is only meaningful when {@see type} is `tinyint`, `smallint`, `integer` * or `bigint`. @@ -282,12 +331,25 @@ public function load(array $info): static; * * ```php * $columns = [ - * 'id' => $this->primaryKey()->name('id'), + * 'id' => ColumnBuilder::primaryKey()->name('id'), * ]; * ``` + * + * @deprecated Will be removed in version 2.0. */ public function name(string|null $name): static; + /** + * Whether the column is not nullable. + * + * ```php + * $columns = [ + * 'description' => ColumnBuilder::text()->notNull(), + * ]; + * ``` + */ + public function notNull(bool $notNull = true): static; + /** * Converts the input value according to {@see phpType} after retrieval from the database. * @@ -301,8 +363,10 @@ public function phpTypecast(mixed $value): mixed; * * ```php * $columns = [ - * 'price' => $this->decimal(10, 2)->precision(10), + * 'price' => ColumnBuilder::decimal(10, 2)->precision(10), * ]; + * + * @deprecated Use {@see size()} instead. Will be removed in version 2.0. */ public function precision(int|null $precision): static; @@ -311,19 +375,34 @@ public function precision(int|null $precision): static; * * ```php * $columns = [ - * 'id' => $this->primaryKey(true), + * 'id' => ColumnBuilder::primaryKey(), * ]; * ``` */ public function primaryKey(bool $isPrimaryKey = true): static; + /** + * The reference to the foreign key constraint. + * + * ```php + * $reference = new ForeignKeyConstraint(); + * $reference->foreignTableName('user'); + * $reference->foreignColumnNames(['id']); + * + * $columns = [ + * 'user_id' => ColumnBuilder::integer()->reference($reference), + * ]; + * ``` + */ + public function reference(ForeignKeyConstraint|null $reference): static; + /** * The scale is the number of digits to the right of the decimal point and is only meaningful when {@see type} is * `decimal`. * * ```php * $columns = [ - * 'price' => $this->decimal(10, 2)->scale(2), + * 'price' => ColumnBuilder::decimal(10, 2)->scale(2), * ]; * ``` */ @@ -336,7 +415,7 @@ public function scale(int|null $scale): static; * * ```php * $columns = [ - * 'name' => $this->string()->size(255), + * 'name' => ColumnBuilder::string()->size(255), * ]; * ``` */ @@ -347,20 +426,31 @@ public function size(int|null $size): static; * * ```php * $columns = [ - * 'description' => $this->text()->type('text'), + * 'description' => ColumnBuilder::text()->type('text'), * ]; * * @psalm-param ColumnType::* $type */ public function type(string $type): static; + /** + * Whether the column has a unique index. + * + * ```php + * $columns = [ + * 'username' => ColumnBuilder::string()->unique(), + * ]; + * ``` + */ + public function unique(bool $unique = true): static; + /** * Whether the column type is an unsigned integer. * It's a data type that can only represent positive whole numbers only. * * ```php * $columns = [ - * 'age' => $this->integer()->unsigned(), + * 'age' => ColumnBuilder::integer()->unsigned(), * ]; * ``` */ diff --git a/src/Syntax/ColumnDefinitionParser.php b/src/Syntax/ColumnDefinitionParser.php index a81f79e15..7c66953d0 100644 --- a/src/Syntax/ColumnDefinitionParser.php +++ b/src/Syntax/ColumnDefinitionParser.php @@ -86,7 +86,6 @@ private function sizeInfo(string $size): array $info = [ 'size' => (int) $values[0], - 'precision' => (int) $values[0], ]; if (isset($values[1])) { diff --git a/tests/Common/CommonSchemaTest.php b/tests/Common/CommonSchemaTest.php index 1fad7be35..3f2ffd6fe 100644 --- a/tests/Common/CommonSchemaTest.php +++ b/tests/Common/CommonSchemaTest.php @@ -858,9 +858,9 @@ protected function columnSchema(array $columns, string $table): void ); $this->assertSame($expected['type'], $column->getType(), "type of column $name does not match."); $this->assertSame( - $expected['allowNull'], - $column->isAllowNull(), - "allowNull of column $name does not match." + $expected['notNull'], + $column->isNotNull(), + "notNull of column $name does not match." ); $this->assertSame( $expected['autoIncrement'], @@ -873,11 +873,6 @@ protected function columnSchema(array $columns, string $table): void "enumValues of column $name does not match." ); $this->assertSame($expected['size'], $column->getSize(), "size of column $name does not match."); - $this->assertSame( - $expected['precision'], - $column->getPrecision(), - "precision of column $name does not match." - ); $this->assertSame($expected['scale'], $column->getScale(), "scale of column $name does not match."); @@ -899,6 +894,14 @@ protected function columnSchema(array $columns, string $table): void ); } + if (isset($expected['unique'])) { + $this->assertSame( + $expected['unique'], + $column->isUnique(), + "unique of column $name does not match" + ); + } + if (isset($expected['unsigned'])) { $this->assertSame( $expected['unsigned'], @@ -929,7 +932,6 @@ protected function columnSchema(array $columns, string $table): void 'phpType' => $arrayColumn->getPhpType(), 'enumValues' => $arrayColumn->getEnumValues(), 'size' => $arrayColumn->getSize(), - 'precision' => $arrayColumn->getPrecision(), 'scale' => $arrayColumn->getScale(), ], "array column of column $name does not match" diff --git a/tests/Db/Schema/ColumnSchemaTest.php b/tests/Db/Schema/ColumnSchemaTest.php index 65e7277cf..71852b1a3 100644 --- a/tests/Db/Schema/ColumnSchemaTest.php +++ b/tests/Db/Schema/ColumnSchemaTest.php @@ -5,6 +5,7 @@ namespace Yiisoft\Db\Tests\Db\Schema; use PHPUnit\Framework\TestCase; +use Yiisoft\Db\Constraint\ForeignKeyConstraint; use Yiisoft\Db\Tests\Support\Stub\ColumnSchema; /** @@ -18,7 +19,7 @@ public function testAllowNull(): void { $column = new ColumnSchema(); - $this->assertFalse($column->isAllowNull()); + $this->assertTrue($column->isAllowNull()); $this->assertSame($column, $column->allowNull()); $this->assertTrue($column->isAllowNull()); @@ -48,6 +49,19 @@ public function testAutoIncrement(): void $this->assertTrue($column->isAutoIncrement()); } + public function testCheck(): void + { + $column = new ColumnSchema(); + + $this->assertNull($column->getCheck()); + $this->assertSame($column, $column->check('age > 0')); + $this->assertSame('age > 0', $column->getCheck()); + + $column->check(null); + + $this->assertNull($column->getCheck()); + } + public function testComment(): void { $column = new ColumnSchema(); @@ -153,6 +167,23 @@ public function testName(): void $this->assertSame('', $column->getName()); } + public function testNotNull(): void + { + $column = new ColumnSchema(); + + $this->assertFalse($column->isNotNull()); + $this->assertSame($column, $column->notNull()); + $this->assertTrue($column->isNotNull()); + + $column->notNull(false); + + $this->assertFalse($column->isNotNull()); + + $column->notNull(true); + + $this->assertTrue($column->isNotNull()); + } + public function testPrecision(): void { $column = new ColumnSchema(); @@ -183,6 +214,20 @@ public function testPrimaryKey(): void $this->assertTrue($column->isPrimaryKey()); } + public function testReference(): void + { + $column = new ColumnSchema(); + $fk = new ForeignKeyConstraint(); + + $this->assertNull($column->getReference()); + $this->assertSame($column, $column->reference($fk)); + $this->assertSame($fk, $column->getReference()); + + $column->reference(null); + + $this->assertNull($column->getReference()); + } + public function testScale(): void { $column = new ColumnSchema(); @@ -222,6 +267,23 @@ public function testType(): void $this->assertSame('', $column->getType()); } + public function testUnique(): void + { + $column = new ColumnSchema(); + + $this->assertFalse($column->isUnique()); + $this->assertSame($column, $column->unique()); + $this->assertTrue($column->isUnique()); + + $column->unique(false); + + $this->assertFalse($column->isUnique()); + + $column->unique(true); + + $this->assertTrue($column->isUnique()); + } + public function testUnsigned(): void { $column = new ColumnSchema(); diff --git a/tests/Provider/ColumnBuilderProvider.php b/tests/Provider/ColumnBuilderProvider.php index 7deff7338..ea4d997f9 100644 --- a/tests/Provider/ColumnBuilderProvider.php +++ b/tests/Provider/ColumnBuilderProvider.php @@ -23,9 +23,9 @@ class ColumnBuilderProvider 'getExtra' => null, 'getScale' => null, 'getSize' => null, - 'isAllowNull' => false, 'isAutoIncrement' => false, 'isComputed' => false, + 'isNotNull' => false, 'isPrimaryKey' => false, 'isUnsigned' => false, ]; diff --git a/tests/Provider/ColumnDefinitionParserProvider.php b/tests/Provider/ColumnDefinitionParserProvider.php index 7d2b4cabc..2ad24ab29 100644 --- a/tests/Provider/ColumnDefinitionParserProvider.php +++ b/tests/Provider/ColumnDefinitionParserProvider.php @@ -11,11 +11,11 @@ public static function parse(): array return [ ['', ['db_type' => '']], ['int', ['db_type' => 'int']], - ['int(10)', ['db_type' => 'int', 'size' => 10, 'precision' => 10]], + ['int(10)', ['db_type' => 'int', 'size' => 10]], ['int UNSIGNED', ['db_type' => 'int', 'unsigned' => true]], - ['int(10) UNSIGNED', ['db_type' => 'int', 'size' => 10, 'precision' => 10, 'unsigned' => true]], - ['int(10) UNSIGNED NOT NULL', ['db_type' => 'int', 'size' => 10, 'precision' => 10, 'unsigned' => true, 'extra' => 'NOT NULL']], - ['int(10) NOT NULL', ['db_type' => 'int', 'size' => 10, 'precision' => 10, 'extra' => 'NOT NULL']], + ['int(10) UNSIGNED', ['db_type' => 'int', 'size' => 10, 'unsigned' => true]], + ['int(10) UNSIGNED NOT NULL', ['db_type' => 'int', 'size' => 10, 'unsigned' => true, 'extra' => 'NOT NULL']], + ['int(10) NOT NULL', ['db_type' => 'int', 'size' => 10, 'extra' => 'NOT NULL']], ['text NOT NULL', ['db_type' => 'text', 'extra' => 'NOT NULL']], ["enum('a','b','c')", ['db_type' => 'enum', 'enum_values' => ['a', 'b', 'c']]], ["enum('a','b','c') NOT NULL", ['db_type' => 'enum', 'enum_values' => ['a', 'b', 'c'], 'extra' => 'NOT NULL']], diff --git a/tests/Provider/ColumnSchemaProvider.php b/tests/Provider/ColumnSchemaProvider.php index 83bf35b71..9bcbe4bca 100644 --- a/tests/Provider/ColumnSchemaProvider.php +++ b/tests/Provider/ColumnSchemaProvider.php @@ -8,6 +8,7 @@ use stdClass; use Yiisoft\Db\Command\Param; use Yiisoft\Db\Constant\ColumnType; +use Yiisoft\Db\Constraint\ForeignKeyConstraint; use Yiisoft\Db\Expression\Expression; use Yiisoft\Db\Expression\JsonExpression; use Yiisoft\Db\Constant\PhpType; @@ -256,6 +257,8 @@ public static function load(): array ['auto_increment', false, 'isAutoIncrement', false], ['auto_increment', '1', 'isAutoIncrement', true], ['auto_increment', '0', 'isAutoIncrement', false], + ['check', 'age > 0', 'getCheck', 'age > 0'], + ['check', null, 'getCheck', null], ['comment', 'Lorem ipsum', 'getComment', 'Lorem ipsum'], ['comment', null, 'getComment', null], ['computed', true, 'isComputed', true], @@ -272,16 +275,26 @@ public static function load(): array ['extra', null, 'getExtra', null], ['name', 'name', 'getName', 'name'], ['name', null, 'getName', null], + ['not_null', true, 'isNotNull', true], + ['not_null', false, 'isNotNull', false], + ['not_null', '1', 'isNotNull', true], + ['not_null', '0', 'isNotNull', false], ['precision', 10, 'getPrecision', 10], ['precision', null, 'getPrecision', null], ['primary_key', true, 'isPrimaryKey', true], ['primary_key', false, 'isPrimaryKey', false], ['primary_key', '1', 'isPrimaryKey', true], ['primary_key', '0', 'isPrimaryKey', false], + ['reference', $fk = new ForeignKeyConstraint(), 'getReference', $fk], + ['reference', null, 'getReference', null], ['scale', 2, 'getScale', 2], ['scale', null, 'getScale', null], ['size', 255, 'getSize', 255], ['size', null, 'getSize', null], + ['unique', true, 'isUnique', true], + ['unique', false, 'isUnique', false], + ['unique', '1', 'isUnique', true], + ['unique', '0', 'isUnique', false], ['unsigned', true, 'isUnsigned', true], ['unsigned', false, 'isUnsigned', false], ['unsigned', '1', 'isUnsigned', true],