44
55use yii \base \InvalidConfigException ;
66use yii \base \Object ;
7+ use yii \db \Connection ;
78
89/**
910 * Class TableChange
@@ -34,6 +35,12 @@ class TableChange extends Object
3435 */
3536 public $ schema ;
3637
38+ /**
39+ * @var Connection
40+ * @since 2.9.0
41+ */
42+ public $ db ;
43+
3744 /**
3845 * Returns change value.
3946 * @return array|string|TableColumn|TablePrimaryKey|TableForeignKey|TableIndex
@@ -49,6 +56,7 @@ public function getValue()
4956 'schema ' => $ this ->schema ,
5057 'name ' => $ column ,
5158 'type ' => $ schema ['type ' ],
59+ 'defaultMapping ' => $ this ->db ->schema ->queryBuilder ->typeMap [$ schema ['type ' ]],
5260 'length ' => isset ($ schema ['length ' ]) ? $ schema ['length ' ] : null ,
5361 'isNotNull ' => isset ($ schema ['isNotNull ' ]) ? $ schema ['isNotNull ' ] : null ,
5462 'isUnique ' => isset ($ schema ['isUnique ' ]) ? $ schema ['isUnique ' ] : null ,
@@ -58,6 +66,8 @@ public function getValue()
5866 'append ' => isset ($ schema ['append ' ]) ? $ schema ['append ' ] : null ,
5967 'isUnsigned ' => isset ($ schema ['isUnsigned ' ]) ? $ schema ['isUnsigned ' ] : null ,
6068 'comment ' => !empty ($ schema ['comment ' ]) ? $ schema ['comment ' ] : null ,
69+ 'after ' => !empty ($ schema ['after ' ]) ? $ schema ['after ' ] : null ,
70+ 'isFirst ' => isset ($ schema ['isFirst ' ]) && $ schema ['isFirst ' ] === true ,
6171 ]);
6272 }
6373 return $ columns ;
@@ -74,6 +84,7 @@ public function getValue()
7484 'schema ' => $ this ->schema ,
7585 'name ' => $ this ->data [0 ],
7686 'type ' => $ this ->data [1 ]['type ' ],
87+ 'defaultMapping ' => $ this ->db ->schema ->queryBuilder ->typeMap [$ this ->data [1 ]['type ' ]],
7788 'length ' => isset ($ this ->data [1 ]['length ' ]) ? $ this ->data [1 ]['length ' ] : null ,
7889 'isNotNull ' => isset ($ this ->data [1 ]['isNotNull ' ]) ? $ this ->data [1 ]['isNotNull ' ] : null ,
7990 'isUnique ' => isset ($ this ->data [1 ]['isUnique ' ]) ? $ this ->data [1 ]['isUnique ' ] : null ,
@@ -83,6 +94,8 @@ public function getValue()
8394 'append ' => isset ($ this ->data [1 ]['append ' ]) ? $ this ->data [1 ]['append ' ] : null ,
8495 'isUnsigned ' => isset ($ this ->data [1 ]['isUnsigned ' ]) ? $ this ->data [1 ]['isUnsigned ' ] : null ,
8596 'comment ' => !empty ($ this ->data [1 ]['comment ' ]) ? $ this ->data [1 ]['comment ' ] : null ,
97+ 'after ' => !empty ($ this ->data [1 ]['after ' ]) ? $ this ->data [1 ]['after ' ] : null ,
98+ 'isFirst ' => isset ($ this ->data [1 ]['isFirst ' ]) && $ this ->data [1 ]['isFirst ' ] === true ,
8699 ]);
87100
88101 case 'addPrimaryKey ' :
0 commit comments