File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ Creates a `tree` table with the following structure:
137137``` sql
138138CREATE TABLE `tree ` (
139139 ` id` int (11 ) NOT NULL AUTO_INCREMENT,
140- ` name` text NOT NULL ,
140+ ` name` varchar ( 255 ) NOT NULL ,
141141 ` lft` int (11 ) NOT NULL ,
142142 ` rgt` int (11 ) NOT NULL ,
143143 ` depth` int (11 ) NOT NULL ,
@@ -157,7 +157,7 @@ Creates a `multiple_tree` table with the following structure:
157157CREATE TABLE `multiple_tree ` (
158158 ` id` int (11 ) NOT NULL AUTO_INCREMENT,
159159 ` tree` int (11 ) DEFAULT NULL ,
160- ` name` text NOT NULL ,
160+ ` name` varchar ( 255 ) NOT NULL ,
161161 ` lft` int (11 ) NOT NULL ,
162162 ` rgt` int (11 ) NOT NULL ,
163163 ` depth` int (11 ) NOT NULL ,
Original file line number Diff line number Diff line change @@ -9,16 +9,22 @@ class m250707_103609_tree extends Migration
99 public function safeUp ()
1010 {
1111 $ rawPrimaryKey = 'NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ' ;
12+ $ tableOptions = [];
13+
14+ if ($ this ->db ->driverName === 'mysql ' ) {
15+ $ tableOptions = 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ' ;
16+ }
1217
1318 $ this ->createTable (
1419 '{{%tree}} ' ,
1520 [
1621 'id ' => $ this ->db ->driverName !== 'oci ' ? $ this ->primaryKey ()->notNull () : $ rawPrimaryKey ,
17- 'name ' => $ this ->db -> driverName === ' oci ' ? $ this -> string ()-> notNull () : $ this -> text ( )->notNull (),
22+ 'name ' => $ this ->string (255 )->notNull (),
1823 'lft ' => $ this ->integer ()->notNull (),
1924 'rgt ' => $ this ->integer ()->notNull (),
2025 'depth ' => $ this ->integer ()->notNull (),
2126 ],
27+ $ tableOptions ,
2228 );
2329
2430 $ this ->createIndex ('idx_tree_lft ' , '{{%tree}} ' , 'lft ' );
Original file line number Diff line number Diff line change @@ -10,16 +10,21 @@ public function safeUp()
1010 {
1111 $ rawPrimaryKey = 'NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY ' ;
1212
13+ if ($ this ->db ->driverName === 'mysql ' ) {
14+ $ tableOptions = 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ' ;
15+ }
16+
1317 $ this ->createTable (
1418 '{{%multiple_tree}} ' ,
1519 [
1620 'id ' => $ this ->db ->driverName !== 'oci ' ? $ this ->primaryKey ()->notNull () : $ rawPrimaryKey ,
1721 'tree ' => $ this ->integer ()->null (),
18- 'name ' => $ this ->db -> driverName === ' oci ' ? $ this -> string ()-> notNull () : $ this -> text ( )->notNull (),
22+ 'name ' => $ this ->string (255 )->notNull (),
1923 'lft ' => $ this ->integer ()->notNull (),
2024 'rgt ' => $ this ->integer ()->notNull (),
2125 'depth ' => $ this ->integer ()->notNull (),
2226 ],
27+ $ tableOptions ,
2328 );
2429
2530 $ this ->createIndex ('idx_multiple_tree_tree ' , '{{%multiple_tree}} ' , 'tree ' );
You can’t perform that action at this time.
0 commit comments