1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace App\Console\Commands\Tool;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Database\Schema\Blueprint;
- class createTable extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'createtable';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'create table';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $this->createUserSignTable();
- //$this->createAdVisitTable();
- }
- private function createUserSignTable(){
- $next_month = date('Ym',strtotime('next Month'));
- $sign_table = 'user_sign'.$next_month;
- if (!Schema::hasTable($sign_table)) {
- Schema::create($sign_table, function (Blueprint $table) {
- $table->increments('id');
- $table->integer('uid');
- $table->integer('price');
- $table->date('day');
- $table->integer('sign_time');
- $table->dateTime('created_at');
- $table->dateTime('updated_at');
- $table->index('uid','ink_uid');
- $table->index(['uid','sign_time'],'uid_sign_time');
- });
- }
- $next_next_month = date('Ym',strtotime('+2 Month'));
- $sign_table = 'user_sign'.$next_next_month;
- if (!Schema::hasTable($sign_table)) {
- Schema::create($sign_table, function (Blueprint $table) {
- $table->increments('id');
- $table->integer('uid');
- $table->integer('price');
- $table->date('day');
- $table->integer('sign_time');
- $table->dateTime('created_at');
- $table->dateTime('updated_at');
- $table->index('uid','ink_uid');
- $table->index(['uid','sign_time'],'uid_sign_time');
- });
- }
- }
- private function createAdVisitTable(){
- $next_month = date('Ym',strtotime('next Month'));
- $sign_table = 'ad_visit_stats'.$next_month;
- if (!Schema::hasTable($sign_table)) {
- Schema::create($sign_table, function (Blueprint $table) {
- $table->increments('id');
- $table->integer('uid');
- $table->integer('bid');
- $table->integer('cid');
- $table->char('type',10);
- $table->dateTime('created_at');
- $table->dateTime('updated_at');
- $table->index(['uid','type'],'uid');
- $table->index(['uid','cid','type'],'uid_cid');
- $table->index('uid','o_uid');
- $table->index(['type','created_at'],'type_date');
- });
- }
- }
- }
|