Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
7babecd
Fix-xDbType
siggi-k Jul 6, 2022
a934859
Fix-Nullable (#99)
siggi-k Jul 7, 2022
5870b24
Update README.md
cebe Jul 7, 2022
7754878
Fix-Enum on MariaDb
siggi-k Jul 12, 2022
304cf15
Merge branch 'fix-db-schema' of github.com:siggi-k/yii2-openapi into …
siggi-k Jul 12, 2022
6ae03fb
Fix-numeric (mariaDb)
siggi-k Aug 25, 2022
b92a2ab
test
SOHELAHMED7 Sep 30, 2022
2a7e053
Undo test
SOHELAHMED7 Sep 30, 2022
f12b01c
test
SOHELAHMED7 Sep 30, 2022
d177ed9
Undo test
SOHELAHMED7 Sep 30, 2022
314743e
test2
SOHELAHMED7 Oct 3, 2022
3184ae0
Merge branch '100-timestamp-migrations-do-not-work-in-mariadb' of git…
SOHELAHMED7 Oct 3, 2022
2af51fb
Undo test2
SOHELAHMED7 Oct 3, 2022
96b91b1
Simplify condition
SOHELAHMED7 Oct 3, 2022
2697fe8
Update fixture
SOHELAHMED7 Oct 4, 2022
73fd187
Enhancements
SOHELAHMED7 Oct 4, 2022
0fda678
Fix failing tests
SOHELAHMED7 Oct 4, 2022
540e9ff
Fix style
SOHELAHMED7 Oct 4, 2022
c9aeee7
test
SOHELAHMED7 Nov 2, 2022
fdfe048
undo test
SOHELAHMED7 Nov 2, 2022
3740d5b
Add composer package sam-it/yii2-mariadb
SOHELAHMED7 Nov 2, 2022
4a313cc
Remove enum as there is not enum physical type in \yii\db\pgsql\Schema
SOHELAHMED7 Nov 2, 2022
e0b8e00
Fix error in tests: Remove enum as there is not enum physical type in…
SOHELAHMED7 Nov 2, 2022
1b9f568
Fix errors in tests, fix fixtures, fix mariadb docker image; fix mari…
SOHELAHMED7 Nov 2, 2022
8fb7084
test
SOHELAHMED7 Nov 21, 2022
329866e
undo test
SOHELAHMED7 Nov 21, 2022
58e5772
Merge branches 'master' and '100-timestamp-migrations-do-not-work-in-…
SOHELAHMED7 Nov 21, 2022
4654195
Remove 'without UUID' test case
SOHELAHMED7 Nov 21, 2022
da85359
Remove 'without UUID' test case part 2
SOHELAHMED7 Nov 21, 2022
0b94b2a
Add TODO note [skip ci]
SOHELAHMED7 Nov 21, 2022
99433e1
Remove UUID in tests [skip ci]
SOHELAHMED7 Nov 22, 2022
ee5136c
Convert erroneous tests to failed tests
SOHELAHMED7 Nov 22, 2022
b667ac0
Use real app and real DB everywhere
SOHELAHMED7 Nov 22, 2022
930e39e
Edit GA to Run tests in Docker container in Github action
SOHELAHMED7 Nov 22, 2022
5a3395c
Change vendor of install-docker-compose in GA
SOHELAHMED7 Nov 22, 2022
bf0c9a7
Config GA - WIP
SOHELAHMED7 Nov 22, 2022
1924510
Config GA -part 2 - WIP
SOHELAHMED7 Nov 22, 2022
b4ec082
Config GA -part 3 - WIP
SOHELAHMED7 Nov 22, 2022
95dee95
Config GA -part 4 - WIP
SOHELAHMED7 Nov 22, 2022
a705c84
Config GA -part 5 - WIP
SOHELAHMED7 Nov 22, 2022
e9dea60
Config GA -part 6 - WIP
SOHELAHMED7 Nov 22, 2022
bfa65e2
Config GA -part 7 - WIP
SOHELAHMED7 Nov 22, 2022
17781a8
Fix failing tests and add more tests for Pgsql and Mariadb
SOHELAHMED7 Nov 22, 2022
e4e2488
Fix failing tests and bugs
SOHELAHMED7 Nov 23, 2022
a753d91
Fix enum related bug in failing tests - WIP
SOHELAHMED7 Nov 23, 2022
64b6936
WIP
SOHELAHMED7 Nov 23, 2022
6adae6a
Remove all enum related changes
SOHELAHMED7 Nov 25, 2022
015a1fc
Add TODO in Makefile
SOHELAHMED7 Nov 25, 2022
0a79006
Fix failing tests
SOHELAHMED7 Nov 25, 2022
68718e0
Attempt to fix failing tests in GA
SOHELAHMED7 Nov 25, 2022
f2cacfe
Error message betterment
SOHELAHMED7 Nov 25, 2022
4868df0
last commit ('Error message betterment') didn't seen in Github, check…
SOHELAHMED7 Nov 25, 2022
b32ae65
BLOB, TEXT, GEOMETRY, and JSON data types cannot be assigned a defaul…
SOHELAHMED7 Nov 26, 2022
a3929f0
Fix failing tests caused by x-db-type implementation and running test…
SOHELAHMED7 Nov 26, 2022
54da89a
Cleanup
SOHELAHMED7 Nov 26, 2022
1516dd6
Cleanup 2
SOHELAHMED7 Nov 27, 2022
e8ae746
Fix bug in x-db-type feature + Add tests WIP
SOHELAHMED7 Nov 28, 2022
dbe2ba5
Fix failing test
SOHELAHMED7 Nov 28, 2022
22e3ace
Restructure base DbTestCase and organize tests
SOHELAHMED7 Nov 28, 2022
2f010bf
Add tests for x-db-type for MySQL, MariaDb and PgSQL for cases: fresh…
SOHELAHMED7 Nov 29, 2022
df929e0
Fix failing tests + add change column data type by x-db-type - WIP
SOHELAHMED7 Nov 30, 2022
15b1b68
Trigger Github Action
SOHELAHMED7 Nov 30, 2022
8feea61
Trigger Github Action 2
SOHELAHMED7 Nov 30, 2022
3085986
Trigger Github Action 3
SOHELAHMED7 Nov 30, 2022
9953ede
Trigger Github Action 4
SOHELAHMED7 Nov 30, 2022
632dcb8
Enh Github Action
SOHELAHMED7 Dec 1, 2022
44af514
Fix issue and failing test in implementation of x-db-type
SOHELAHMED7 Dec 1, 2022
109e46d
Enhance tests + organize code
SOHELAHMED7 Dec 2, 2022
5cc77ea
Change PropertySchema
SOHELAHMED7 Dec 2, 2022
fec8a0b
Consider phpType in comparison
SOHELAHMED7 Dec 2, 2022
c3c5367
Strengthen the way tmp column is stored for compareColumn part + fix …
SOHELAHMED7 Dec 3, 2022
7928ef0
Fix style + Implement Pgsql compare column change by new way
SOHELAHMED7 Dec 3, 2022
ac42564
Fix bugs in Decimal related x-db-type changes
SOHELAHMED7 Dec 5, 2022
6e2275d
Refactor migration generation code and add more tests for x-db-type f…
SOHELAHMED7 Dec 6, 2022
fb869ba
Add more tests for x-db-type for MySQL
SOHELAHMED7 Dec 6, 2022
dd0ce9b
Add more tests
SOHELAHMED7 Dec 7, 2022
2180f7a
Add more tests for edit column scenario
SOHELAHMED7 Dec 8, 2022
6a3e1da
Pass the CI
SOHELAHMED7 Dec 8, 2022
30671aa
Add tests for Mariadb + add tooling support to run migrations for mul…
SOHELAHMED7 Dec 8, 2022
d5d0f6f
Fix bug related to DB type with more than one word for MySQL and PgSQ…
SOHELAHMED7 Dec 12, 2022
02d06fa
Tests refactoring and add more x-db-type tests for PgSQL
SOHELAHMED7 Dec 13, 2022
4fb7b28
WIP
SOHELAHMED7 Dec 13, 2022
8449d44
Implement string base add column code - WIP ('double precision precis…
SOHELAHMED7 Dec 13, 2022
2baf6c5
Fix 'double precision precision' issue for x-db-type - WIP + Fix few …
SOHELAHMED7 Dec 14, 2022
3ac7837
Fix failing tests
SOHELAHMED7 Dec 14, 2022
7df1b85
Delete un-necessary file
SOHELAHMED7 Dec 14, 2022
b1cf636
Change addColumn feature in migration for x-db-type
SOHELAHMED7 Dec 17, 2022
8d19fe9
Fix issue for alter column for x-db-type in Pgsql
SOHELAHMED7 Dec 19, 2022
7f64da0
Fix style
SOHELAHMED7 Dec 19, 2022
477c38b
Fix tests for fresh tables scenario
SOHELAHMED7 Dec 19, 2022
0070b63
Enhance PR
SOHELAHMED7 Dec 20, 2022
595f25f
Add more tests
SOHELAHMED7 Dec 20, 2022
cbd1dc1
Enhance PR
SOHELAHMED7 Dec 20, 2022
a49eee1
Fix bugs + add more tests
SOHELAHMED7 Dec 20, 2022
984382f
Add docs
SOHELAHMED7 Dec 20, 2022
a00a8da
Fix failing test
SOHELAHMED7 Dec 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix issue for alter column for x-db-type in Pgsql
  • Loading branch information
SOHELAHMED7 committed Dec 19, 2022
commit 8d19fe91c637fffaf82257f33cd47574ba3ad9a1
26 changes: 25 additions & 1 deletion src/lib/ColumnToCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,39 @@ class ColumnToCode
*/
private $alter;

/**
* @var bool
* Q. How does it differ from `$alter` and why it is needed?
* A. Pgsql alter column data type does not support NULL, DEFAULT etc value. We just have to provide new data type.
* NULL will be handled SET NULL/SET NOT NULL
* DEFAULT will be handled by SET DEFAULT ...
* This property is only used in Pgsql DB and for alter column data type cases
*/
private $alterByXDbType;

/**
* ColumnToCode constructor.
* @param \yii\db\Schema $dbSchema
* @param \yii\db\ColumnSchema $column
* @param bool $fromDb (if from database we prefer column type for usage, from schema - dbType)
* @param bool $alter (flag for resolve quotes that is different for create and alter)
* @param bool $raw see @property $raw above for docs
* @param bool $alterByXDbType see @alterByXDbType $raw above for docs
*/
public function __construct(
Schema $dbSchema,
ColumnSchema $column,
bool $fromDb = false,
bool $alter = false,
bool $raw = false
bool $raw = false,
bool $alterByXDbType = false
) {
$this->dbSchema = $dbSchema;
$this->column = $column;
$this->fromDb = $fromDb;
$this->alter = $alter;
$this->raw = $raw;
$this->alterByXDbType = $alterByXDbType;

// TODO docs why we use `property_exists()`
if (property_exists($this->column, 'xDbType') && is_string($this->column->xDbType) && !empty($this->column->xDbType)) {
Expand Down Expand Up @@ -145,6 +158,9 @@ public function getCode(bool $quoted = false):string
if (ApiGenerator::isMysql() && $this->isEnum()) {
return $quoted ? '"' . str_replace("\'", "'", $code) . '"' : $code;
}
if (ApiGenerator::isPostgres() && $this->alterByXDbType) {
return $quoted ? "'" . $this->rawParts['type'] . "'" : $this->rawParts['type'];
}
return $quoted ? "'" . $code . "'" : $code;
}

Expand All @@ -161,6 +177,10 @@ public function getAlterExpression(bool $addUsingExpression = false):string
.' USING "'.$this->column->name.'"::'.$this->typeWithoutSize($this->rawParts['type'])."'";
}

if (ApiGenerator::isPostgres() && $this->alterByXDbType) {
return "'" . $this->rawParts['type'] . "'";
}

return $this->isBuiltinType
? '$this->' . $this->fluentParts['type'].'->'.$this->fluentParts['nullable']
: "'" . $this->rawParts['type'] . " ".$this->rawParts['nullable']."'";
Expand Down Expand Up @@ -329,6 +349,10 @@ private function resolve():void
*/
private function getIsBuiltinType($type, $dbType)
{
if (property_exists($this->column, 'xDbType') && is_string($this->column->xDbType) && !empty($this->column->xDbType)) {
return false;
}

if ($this->isEnum() && ApiGenerator::isMariaDb()) {
return false;
}
Expand Down
50 changes: 48 additions & 2 deletions src/lib/migrations/MigrationRecordBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace cebe\yii2openapi\lib\migrations;

use cebe\yii2openapi\generator\ApiGenerator;
use cebe\yii2openapi\lib\ColumnToCode;
use Yii;
use yii\db\ColumnSchema;
Expand Down Expand Up @@ -37,6 +38,9 @@ final class MigrationRecordBuilder

public const ALTER_COLUMN = MigrationRecordBuilder::INDENT . "\$this->alterColumn('%s', '%s', %s);";

public const ALTER_COLUMN_RAW = MigrationRecordBuilder::INDENT . "\$this->db->createCommand(\"ALTER TABLE %s MODIFY %s %s\")->execute();";
public const ALTER_COLUMN_RAW_PGSQL = MigrationRecordBuilder::INDENT . "\$this->db->createCommand(\"ALTER TABLE %s ALTER COLUMN %s SET DATA TYPE %s\")->execute();";

/**
* @var \yii\db\Schema
*/
Expand Down Expand Up @@ -94,6 +98,10 @@ public function addColumn(string $tableAlias, ColumnSchema $column):string
*/
public function addDbColumn(string $tableAlias, ColumnSchema $column):string
{
if (property_exists($column, 'xDbType') && is_string($column->xDbType) && !empty($column->xDbType)) {
$converter = $this->columnToCode($column, true);
return sprintf(self::ADD_COLUMN_RAW, $tableAlias, $column->name, $converter->getCode());
}
$converter = $this->columnToCode($column, true);
return sprintf(self::ADD_COLUMN, $tableAlias, $column->name, $converter->getCode(true));
}
Expand All @@ -103,6 +111,13 @@ public function addDbColumn(string $tableAlias, ColumnSchema $column):string
*/
public function alterColumn(string $tableAlias, ColumnSchema $column):string
{
if (property_exists($column, 'xDbType') && is_string($column->xDbType) && !empty($column->xDbType)) {
$converter = $this->columnToCode($column, true, false, true, true);
return sprintf(
ApiGenerator::isPostgres() ? self::ALTER_COLUMN_RAW_PGSQL : self::ALTER_COLUMN_RAW,
$tableAlias, $column->name, $converter->getCode()
);
}
$converter = $this->columnToCode($column, true);
return sprintf(self::ALTER_COLUMN, $tableAlias, $column->name, $converter->getCode(true));
}
Expand All @@ -112,6 +127,15 @@ public function alterColumn(string $tableAlias, ColumnSchema $column):string
*/
public function alterColumnType(string $tableAlias, ColumnSchema $column, bool $addUsing = false):string
{
if (property_exists($column, 'xDbType') && is_string($column->xDbType) && !empty($column->xDbType)) {
$converter = $this->columnToCode($column, false, false, true, true);
return sprintf(
ApiGenerator::isPostgres() ? self::ALTER_COLUMN_RAW_PGSQL : self::ALTER_COLUMN_RAW,
$tableAlias,
$column->name,
rtrim(ltrim($converter->getAlterExpression($addUsing), "'"), "'")
);
}
$converter = $this->columnToCode($column, false);
return sprintf(self::ALTER_COLUMN, $tableAlias, $column->name, $converter->getAlterExpression($addUsing));
}
Expand All @@ -121,6 +145,15 @@ public function alterColumnType(string $tableAlias, ColumnSchema $column, bool $
*/
public function alterColumnTypeFromDb(string $tableAlias, ColumnSchema $column, bool $addUsing = false) :string
{
if (property_exists($column, 'xDbType') && is_string($column->xDbType) && !empty($column->xDbType)) {
$converter = $this->columnToCode($column, true, false, true, true);
return sprintf(
ApiGenerator::isPostgres() ? self::ALTER_COLUMN_RAW_PGSQL : self::ALTER_COLUMN_RAW,
$tableAlias,
$column->name,
rtrim(ltrim($converter->getAlterExpression($addUsing), "'"), "'")
);
}
$converter = $this->columnToCode($column, true);
return sprintf(self::ALTER_COLUMN, $tableAlias, $column->name, $converter->getAlterExpression($addUsing));
}
Expand Down Expand Up @@ -225,9 +258,22 @@ public function dropIndex(string $tableAlias, string $indexName):string
/**
* @throws \yii\base\InvalidConfigException
*/
private function columnToCode(ColumnSchema $column, bool $fromDb = false, bool $alter = false): ColumnToCode
private function columnToCode(
ColumnSchema $column,
bool $fromDb = false,
bool $alter = false,
bool $raw = false,
bool $alterByXDbType = false
): ColumnToCode
{
return Yii::createObject(ColumnToCode::class, [$this->dbSchema, $column, $fromDb, $alter]);
return Yii::createObject(ColumnToCode::class, [
$this->dbSchema,
$column,
$fromDb,
$alter,
$raw,
$alterByXDbType
]);
}

// public static function bnm789() // TODO rename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function safeUp()
$this->addColumn('{{%v2_users}}', 'login', $this->text()->notNull());
$this->dropColumn('{{%v2_users}}', 'username');
$this->alterColumn('{{%v2_users}}', 'created_at', "DROP DEFAULT");
$this->alterColumn('{{%v2_users}}', 'email', 'varchar(255) NOT NULL');
$this->db->createCommand("ALTER TABLE {{%v2_users}} ALTER COLUMN email SET DATA TYPE varchar(255)")->execute();
$this->dropIndex('v2_users_username_key', '{{%v2_users}}');
$this->createIndex('v2_users_login_key', '{{%v2_users}}', 'login', true);
$this->createIndex('v2_users_flags_hash_index', '{{%v2_users}}', 'flags', 'hash');
Expand Down
2 changes: 2 additions & 0 deletions tests/specs/x_db_type/fresh/pgsql/x_db_type_pgsql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ components:
json_col:
type: string
x-db-type: text
nullable: false
default: fox jumps over dog
numeric_col:
type: string
x-db-type: double precision
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* Table for Alldbdatatype
*/
class m200000_000000_create_table_alldbdatatypes extends \yii\db\Migration
{
public function up()
{
$this->createTable('{{%alldbdatatypes}}', [
'id' => $this->bigPrimaryKey(),
0 => 'string_col varchar(255) NULL DEFAULT NULL',
1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
2 => 'text_col text NULL DEFAULT NULL',
3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
4 => 'char_4_col char(4) NULL DEFAULT NULL',
5 => 'char_5_col char NULL DEFAULT NULL',
6 => 'char_6_col char NOT NULL',
7 => 'char_7_col char(6) NOT NULL',
8 => 'char_8_col char NULL DEFAULT \'d\'',
9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
11 => 'blob_col blob NULL DEFAULT NULL',
12 => 'bit_col bit NULL DEFAULT NULL',
13 => 'bit_2 bit(1) NULL DEFAULT NULL',
14 => 'bit_3 bit(64) NULL DEFAULT NULL',
15 => 'ti tinyint NULL DEFAULT NULL',
16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
18 => 'si_col smallint NULL DEFAULT NULL',
19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
21 => 'bi bigint NULL DEFAULT NULL',
22 => 'int_col int NULL DEFAULT NULL',
23 => 'int_col_2 integer NULL DEFAULT NULL',
24 => 'numeric_col numeric NULL DEFAULT NULL',
25 => 'float_col float NULL DEFAULT NULL',
26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
27 => 'float_3 float(8) NULL DEFAULT NULL',
28 => 'double_col double NULL DEFAULT NULL',
29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
30 => 'double_p_2 double precision NULL DEFAULT NULL',
31 => 'real_col real NULL DEFAULT NULL',
32 => 'date_col date NULL DEFAULT NULL',
33 => 'time_col time NULL DEFAULT NULL',
34 => 'datetime_col datetime NULL DEFAULT NULL',
35 => 'timestamp_col timestamp NULL DEFAULT NULL',
36 => 'year_col year NULL DEFAULT NULL',
37 => 'json_col json NOT NULL',
38 => 'blob_def blob NULL DEFAULT \'the blob\'',
39 => 'text_def text NULL DEFAULT \'the text\'',
40 => 'json_def json NOT NULL DEFAULT \'{"a":"b"}\'',
]);
}

public function down()
{
$this->dropTable('{{%alldbdatatypes}}');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* Table for Editcolumn
*/
class m200000_000001_create_table_editcolumns extends \yii\db\Migration
{
public function up()
{
$this->createTable('{{%editcolumns}}', [
'id' => $this->primaryKey(),
0 => 'name varchar(255) NOT NULL DEFAULT \'Horse-2\'',
'tag' => $this->text()->null()->defaultValue(null),
1 => 'first_name varchar(255) NULL DEFAULT NULL',
'string_col' => $this->text()->null()->defaultValue(null),
2 => 'dec_col decimal(12,2) NULL DEFAULT 3.14',
3 => 'str_col_def varchar(3) NOT NULL',
4 => 'json_col text NULL DEFAULT NULL',
5 => 'numeric_col double precision NULL DEFAULT NULL',
]);
}

public function down()
{
$this->dropTable('{{%editcolumns}}');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* Table for Newcolumn
*/
class m200000_000002_change_table_newcolumns extends \yii\db\Migration
{
public function up()
{
$this->db->createCommand("ALTER TABLE {{%newcolumns}} ADD COLUMN dec_col decimal(12,4) NULL DEFAULT NULL")->execute();
$this->db->createCommand("ALTER TABLE {{%newcolumns}} ADD COLUMN json_col json NOT NULL")->execute();
$this->addColumn('{{%newcolumns}}', 'last_name', $this->text()->null()->defaultValue(null));
$this->db->createCommand("ALTER TABLE {{%newcolumns}} ADD COLUMN numeric_col double precision NULL DEFAULT NULL")->execute();
$this->db->createCommand("ALTER TABLE {{%newcolumns}} ADD COLUMN varchar_col varchar(5) NULL DEFAULT NULL")->execute();
}

public function down()
{
$this->dropColumn('{{%newcolumns}}', 'varchar_col');
$this->dropColumn('{{%newcolumns}}', 'numeric_col');
$this->dropColumn('{{%newcolumns}}', 'last_name');
$this->dropColumn('{{%newcolumns}}', 'json_col');
$this->dropColumn('{{%newcolumns}}', 'dec_col');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* Table for Pristine
*/
class m200000_000003_create_table_pristines extends \yii\db\Migration
{
public function up()
{
$this->createTable('{{%pristines}}', [
0 => 'custom_id_col integer primary key auto_increment NOT NULL',
1 => 'name text NOT NULL',
'tag' => $this->text()->null()->defaultValue("4 leg"),
2 => 'new_col varchar(17) NULL DEFAULT NULL',
3 => 'col_5 decimal(12,4) NULL DEFAULT NULL',
4 => 'col_6 decimal(11,2) NULL DEFAULT NULL',
5 => 'col_7 decimal(10,2) NULL DEFAULT NULL',
6 => 'col_8 json NOT NULL',
7 => 'col_9 varchar(9) NULL DEFAULT NULL',
8 => 'col_10 varchar(10) NULL DEFAULT NULL',
9 => 'col_11 text NULL DEFAULT NULL',
]);
}

public function down()
{
$this->dropTable('{{%pristines}}');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

/**
* Table for Alldbdatatype
*/
class m200000_000000_create_table_alldbdatatypes extends \yii\db\Migration
{
public function up()
{
$this->createTable('{{%alldbdatatypes}}', [
'id' => $this->bigPrimaryKey(),
0 => 'string_col varchar(255) NULL DEFAULT NULL',
1 => 'varchar_col varchar(132) NULL DEFAULT NULL',
2 => 'text_col text NULL',
3 => 'varchar_4_col varchar(4) NULL DEFAULT NULL',
4 => 'char_4_col char(4) NULL DEFAULT NULL',
5 => 'char_5_col char NULL DEFAULT NULL',
6 => 'char_6_col char NOT NULL',
7 => 'char_7_col char(6) NOT NULL',
8 => 'char_8_col char NULL DEFAULT \'d\'',
9 => 'decimal_col decimal(12,3) NULL DEFAULT NULL',
10 => 'varbinary_col varbinary(5) NULL DEFAULT NULL',
11 => 'blob_col blob NULL',
12 => 'bit_col bit NULL DEFAULT NULL',
13 => 'bit_2 bit(1) NULL DEFAULT NULL',
14 => 'bit_3 bit(64) NULL DEFAULT NULL',
15 => 'ti tinyint NULL DEFAULT NULL',
16 => 'ti_2 tinyint(1) NULL DEFAULT NULL',
17 => 'ti_3 tinyint(2) NULL DEFAULT NULL',
18 => 'si_col smallint NULL DEFAULT NULL',
19 => 'si_col_2 smallint unsigned zerofill NULL DEFAULT NULL',
20 => 'mi mediumint(10) unsigned zerofill comment "comment" NULL DEFAULT 7',
21 => 'bi bigint NULL DEFAULT NULL',
22 => 'int_col int NULL DEFAULT NULL',
23 => 'int_col_2 integer NULL DEFAULT NULL',
24 => 'numeric_col numeric NULL DEFAULT NULL',
25 => 'float_col float NULL DEFAULT NULL',
26 => 'float_2 float(10, 2) NULL DEFAULT NULL',
27 => 'float_3 float(8) NULL DEFAULT NULL',
28 => 'double_col double NULL DEFAULT NULL',
29 => 'double_p double precision(10,2) NULL DEFAULT NULL',
30 => 'double_p_2 double precision NULL DEFAULT NULL',
31 => 'real_col real NULL DEFAULT NULL',
32 => 'date_col date NULL DEFAULT NULL',
33 => 'time_col time NULL DEFAULT NULL',
34 => 'datetime_col datetime NULL DEFAULT NULL',
35 => 'timestamp_col timestamp NULL DEFAULT NULL',
36 => 'year_col year NULL DEFAULT NULL',
37 => 'json_col json NOT NULL',
38 => 'blob_def blob NULL',
39 => 'text_def text NULL',
40 => 'json_def json NOT NULL',
]);
}

public function down()
{
$this->dropTable('{{%alldbdatatypes}}');
}
}
Loading