diff --git a/console/controllers/FillTableAController.php b/console/controllers/FillTableAController.php new file mode 100644 index 0000000..19c8948 --- /dev/null +++ b/console/controllers/FillTableAController.php @@ -0,0 +1,34 @@ +records_count); + for( $i=0;$i<$this->records_count;$i++ ) { + Yii::$app->db->createCommand()->insert('table_a',['value'=>$security->generateRandomString(8)])->execute(); + Console::updateProgress($i,$this->records_count); + } + Console::endProgress('done'.PHP_EOL); + + return 0; + } +} \ No newline at end of file diff --git a/console/controllers/MoveDataController.php b/console/controllers/MoveDataController.php new file mode 100644 index 0000000..7166867 --- /dev/null +++ b/console/controllers/MoveDataController.php @@ -0,0 +1,24 @@ +db->createCommand('SELECT * FROM table_a')->queryAll(); + + Yii::$app->db->createCommand()->batchInsert('table_b',['id','value'],$data_a)->execute(); + + return 0; + } +} \ No newline at end of file diff --git a/console/migrations/m190516_082608_create_table_a.php b/console/migrations/m190516_082608_create_table_a.php new file mode 100644 index 0000000..60a78c8 --- /dev/null +++ b/console/migrations/m190516_082608_create_table_a.php @@ -0,0 +1,25 @@ +createTable( + 'table_a', + [ + 'id' => $this->primaryKey(), + 'value' => $this->string(), + ] + ); + } + + public function safeDown() + { + $this->dropTable('table_a'); + } +} diff --git a/console/migrations/m190516_090632_create_table_b.php b/console/migrations/m190516_090632_create_table_b.php new file mode 100644 index 0000000..6160e01 --- /dev/null +++ b/console/migrations/m190516_090632_create_table_b.php @@ -0,0 +1,25 @@ +createTable( + 'table_b', + [ + 'id' => $this->primaryKey(), + 'value' => $this->string(), + ] + ); + } + + public function safeDown() + { + $this->dropTable('table_b'); + } +}