RebuildDb.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\Console\Commands;
  3. use app\backend\modules\member\models\Member;
  4. use app\common\models\AccountWechats;
  5. use app\frontend\modules\member\models\MemberUniqueModel;
  6. use ClassesWithParents\D;
  7. use Illuminate\Console\Command;
  8. use Illuminate\Support\Facades\DB;
  9. class RebuildDb extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'rebuildDb ';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. //重构数据库
  23. protected $description = 'To Rebuild The Database(重构数据库) ';
  24. /**
  25. * Create a new command instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. }
  33. /**
  34. * Execute the console command.
  35. *
  36. * @return mixed
  37. */
  38. public function handle()
  39. {
  40. //\Log::debug('数据重构1');
  41. //Schema::dropIfExists('yz_goods_param');
  42. \Log::debug('数据重构2');
  43. require_once '../../../install.php';
  44. \Log::debug('数据重构3');
  45. DB::select('truncate table'. DB::getTablePrefix(). '_migrations;');
  46. \Log::debug('数据重构4');
  47. \Artisan::call('migrate',['--force' => true]);
  48. }
  49. }