@@ -125,15 +125,15 @@ public function testDumpComplexStructureUp(): void
125
125
$ output .= "\$this->table('table_2', 'id') \n ->addColumn('id', 'integer', ['autoincrement' => true]) \n ->addColumn('title', 'string', ['length' => 100]) \n ->addColumn('is_active', 'boolean', ['default' => true]) \n ->addColumn('fk_table_1_id', 'integer') \n ->create(); \n\n" ;
126
126
127
127
$ output .= "\$this->table('table_3', 'id') \n ->addColumn('id', 'integer', ['autoincrement' => true]) \n ->addColumn('title', 'string') \n ->addColumn('status', 'enum', ['values' => ['new', 'processed', 'done'], 'default' => 'new']) \n ->addColumn('fk_table_1_id', 'integer', ['null' => true]) \n ->create(); \n\n" ;
128
- $ output .= "\$this->table('table_4', 'identifier') \n ->addColumn('identifier', 'uuid') \n ->addColumn('col_integer', 'integer') \n ->addColumn('col_string', 'string') \n ->addColumn('col_char', 'char') \n ->addColumn('col_timestamp', 'timestamp', ['null' => true, 'default' => 'CURRENT_TIMESTAMP']) \n ->addColumn('alias', 'string') \n ->addColumn('sku', 'string') \n ->addUniqueConstraint(['alias', 'sku'], 'u_alias_sku') \n ->addIndex([new \Phoenix\Database\Element\IndexColumn('col_string', ['order' => 'DESC']), new \Phoenix\Database\Element\IndexColumn('col_integer', ['order' => 'DESC'])], '', '', 'idx_table_4_col_string_odesc_col_integer_odesc') \n ->create(); " ;
128
+ $ output .= "\$this->table('table_4', 'identifier') \n ->addColumn('identifier', 'uuid') \n ->addColumn('col_integer', 'integer') \n ->addColumn('col_string', 'string', ['default' => ''] ) \n ->addColumn('col_char', 'char') \n ->addColumn('col_timestamp', 'timestamp', ['null' => true, 'default' => 'CURRENT_TIMESTAMP']) \n ->addColumn('alias', 'string') \n ->addColumn('sku', 'string') \n ->addUniqueConstraint(['alias', 'sku'], 'u_alias_sku') \n ->addIndex([new \Phoenix\Database\Element\IndexColumn('col_string', ['order' => 'DESC']), new \Phoenix\Database\Element\IndexColumn('col_integer', ['order' => 'DESC'])], '', '', 'idx_table_4_col_string_odesc_col_integer_odesc') \n ->create(); " ;
129
129
$ this ->assertEquals ($ output , $ dumper ->dumpTables ($ tables , 'up ' ));
130
130
131
131
$ dumper = new Dumper ("\t" );
132
132
$ output = "\$this->table('table_1', 'id') \n\t->setCharset('utf8') \n\t->setCollation('utf8_general_ci') \n\t->addColumn('id', 'integer', ['autoincrement' => true]) \n\t->addColumn('title', 'string', ['charset' => 'utf16', 'collation' => 'utf16_general_ci']) \n\t->addColumn('alias', 'string') \n\t->addColumn('bodytext', 'text') \n\t->addColumn('price', 'decimal', ['default' => 0.01]) \n\t->addColumn('sorting', 'biginteger') \n\t->addColumn('sku', 'string') \n\t->addUniqueConstraint('sku', 'u_sku') \n\t->addIndex(new \Phoenix\Database\Element\IndexColumn('alias', ['length' => 10]), 'unique', '', 'idx_table_1_alias_l10') \n\t->create(); \n\n" ;
133
133
$ output .= "\$this->table('table_2', 'id') \n\t->addColumn('id', 'integer', ['autoincrement' => true]) \n\t->addColumn('title', 'string', ['length' => 100]) \n\t->addColumn('is_active', 'boolean', ['default' => true]) \n\t->addColumn('fk_table_1_id', 'integer') \n\t->create(); \n\n" ;
134
134
135
135
$ output .= "\$this->table('table_3', 'id') \n\t->addColumn('id', 'integer', ['autoincrement' => true]) \n\t->addColumn('title', 'string') \n\t->addColumn('status', 'enum', ['values' => ['new', 'processed', 'done'], 'default' => 'new']) \n\t->addColumn('fk_table_1_id', 'integer', ['null' => true]) \n\t->create(); \n\n" ;
136
- $ output .= "\$this->table('table_4', 'identifier') \n\t->addColumn('identifier', 'uuid') \n\t->addColumn('col_integer', 'integer') \n\t->addColumn('col_string', 'string') \n\t->addColumn('col_char', 'char') \n\t->addColumn('col_timestamp', 'timestamp', ['null' => true, 'default' => 'CURRENT_TIMESTAMP']) \n\t->addColumn('alias', 'string') \n\t->addColumn('sku', 'string') \n\t->addUniqueConstraint(['alias', 'sku'], 'u_alias_sku') \n\t->addIndex([new \Phoenix\Database\Element\IndexColumn('col_string', ['order' => 'DESC']), new \Phoenix\Database\Element\IndexColumn('col_integer', ['order' => 'DESC'])], '', '', 'idx_table_4_col_string_odesc_col_integer_odesc') \n\t->create(); " ;
136
+ $ output .= "\$this->table('table_4', 'identifier') \n\t->addColumn('identifier', 'uuid') \n\t->addColumn('col_integer', 'integer') \n\t->addColumn('col_string', 'string', ['default' => ''] ) \n\t->addColumn('col_char', 'char') \n\t->addColumn('col_timestamp', 'timestamp', ['null' => true, 'default' => 'CURRENT_TIMESTAMP']) \n\t->addColumn('alias', 'string') \n\t->addColumn('sku', 'string') \n\t->addUniqueConstraint(['alias', 'sku'], 'u_alias_sku') \n\t->addIndex([new \Phoenix\Database\Element\IndexColumn('col_string', ['order' => 'DESC']), new \Phoenix\Database\Element\IndexColumn('col_integer', ['order' => 'DESC'])], '', '', 'idx_table_4_col_string_odesc_col_integer_odesc') \n\t->create(); " ;
137
137
$ this ->assertEquals ($ output , $ dumper ->dumpTables ($ tables , 'up ' ));
138
138
}
139
139
@@ -291,7 +291,7 @@ private function createComplexStructure(): array
291
291
$ table4 = new MigrationTable ('table_4 ' , 'identifier ' );
292
292
$ table4 ->addColumn ('identifier ' , 'uuid ' );
293
293
$ table4 ->addColumn ('col_integer ' , 'integer ' );
294
- $ table4 ->addColumn ('col_string ' , 'string ' );
294
+ $ table4 ->addColumn ('col_string ' , 'string ' , [ ' default ' => '' ] );
295
295
$ table4 ->addColumn ('col_char ' , 'char ' );
296
296
$ table4 ->addColumn ('col_timestamp ' , 'timestamp ' , ['null ' => true , 'default ' => ColumnSettings::DEFAULT_VALUE_CURRENT_TIMESTAMP ]);
297
297
$ table4 ->addColumn ('alias ' , 'string ' );
0 commit comments