CreateTrackTable.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace App\Console\Commands\CallBack;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Support\Facades\Schema;
  6. class CreateTrackTable extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'create_track_table {--month=}';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '每月创建track表';
  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. $month = $this->option('month');
  37. $month = $month ? $month : date('Ym', strtotime('+1 month'));
  38. $track_table = 'douyin_tracks' . $month;
  39. $trackConn = Schema::connection('track_record');
  40. if (!$trackConn->hasTable($track_table)) {
  41. $trackConn->create($track_table, function (Blueprint $table) {
  42. $table->increments('id');
  43. $table->string('link_source', 16)->comment('去放渠道标识')->default('');
  44. $table->string('link', 8000)->comment('落地页连接')->default('');
  45. $table->string('source', 16)->comment('平台来源')->default('');
  46. $table->string('ip_ua', 32);
  47. $table->string('connection_id', 32)->comment('站点或者推广连接id')->default('');
  48. $table->string('ua', 255);
  49. $table->string('ip', 50);
  50. $table->string('adid', 32)->comment('巨量1.0广告id')->default('');
  51. $table->string('log_time', 20);
  52. $table->string('callback', 2048)->comment('用户点击唯一标识')->default('');
  53. $table->string('advertiser_id', 64)->comment('广告主id')->default('');
  54. $table->string('campaign_id', 64)->comment('广告组id')->default('');
  55. $table->string('creativeid', 64)->comment('创意id')->default('');
  56. $table->timestamps();
  57. $table->index(['connection_id', 'source'], 'idx_channel_id');
  58. $table->index('ip', 'idx_ip');
  59. $table->index('link_source', 'idx_link_source');
  60. $table->index('created_at', 'idx_created_at');
  61. $table->string('project_id', 64)->comment('广告项目id')->default('');
  62. $table->string('promotion_id', 64)->comment('推销id,广告计划id的替代品')->default('');
  63. });
  64. }
  65. }
  66. }