ToolController.php 742 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace console\controllers;
  3. use Yii;
  4. use yii\console\Controller;
  5. use common\components\Migration;
  6. /**
  7. * 小工具
  8. *
  9. * Class ToolController
  10. * @package console\controllers
  11. * @author jianyan74 <751393839@qq.com>
  12. */
  13. class ToolController extends Controller
  14. {
  15. /**
  16. * 批量修改字段类型
  17. *
  18. * ./yii tool/shop-to-store
  19. *
  20. * @return void
  21. */
  22. public function actionShopToStore()
  23. {
  24. $migration = new Migration();
  25. // 表列表
  26. $tables = array_map('array_change_key_case', Yii::$app->db->createCommand('SHOW TABLE STATUS')->queryAll());
  27. foreach ($tables as $table) {
  28. $migration->renameColumn($table['name'], 'shop_id', 'store_id');
  29. }
  30. }
  31. }
粤ICP备19079148号