createTable.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Console\Commands\Tool;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\Schema;
  5. use Illuminate\Database\Schema\Blueprint;
  6. class createTable extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'createtable';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'create table';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function handle()
  35. {
  36. $this->createUserSignTable();
  37. //$this->createAdVisitTable();
  38. }
  39. private function createUserSignTable(){
  40. $next_month = date('Ym',strtotime('next Month'));
  41. $sign_table = 'user_sign'.$next_month;
  42. if (!Schema::hasTable($sign_table)) {
  43. Schema::create($sign_table, function (Blueprint $table) {
  44. $table->increments('id');
  45. $table->integer('uid');
  46. $table->integer('price');
  47. $table->date('day');
  48. $table->integer('sign_time');
  49. $table->dateTime('created_at');
  50. $table->dateTime('updated_at');
  51. $table->index('uid','ink_uid');
  52. $table->index(['uid','sign_time'],'uid_sign_time');
  53. });
  54. }
  55. $next_next_month = date('Ym',strtotime('+2 Month'));
  56. $sign_table = 'user_sign'.$next_next_month;
  57. if (!Schema::hasTable($sign_table)) {
  58. Schema::create($sign_table, function (Blueprint $table) {
  59. $table->increments('id');
  60. $table->integer('uid');
  61. $table->integer('price');
  62. $table->date('day');
  63. $table->integer('sign_time');
  64. $table->dateTime('created_at');
  65. $table->dateTime('updated_at');
  66. $table->index('uid','ink_uid');
  67. $table->index(['uid','sign_time'],'uid_sign_time');
  68. });
  69. }
  70. }
  71. }