<?php

namespace App\Console\Commands\Upgrade;

use Illuminate\Console\Command;

class V20181212Command extends Command
{
    protected $signature = "upgrade:v20181212";

    protected $description = "版本升级脚本|2018-12-12号更新版本升级\n
                            更新内容：\n
                                1. 修改契约数据库架构设计,适应报名+邀请两种参加活动的方式\n
                                2. 更具新架构修改报名、邀请分别与契约的关联逻辑\n
                                3. 增加「匹配契约晚安」功能\n
                                4. 增加「邀请参加契约晚安」功能\n
                            脚本内容: \n
                                1. 修正旧数据的邀请-契约关联\n";

    public function handle()
    {
        $this->upgradeDeed();
    }

    private function upgradeDeed()
    {
        dump("「修正旧数据的邀请-契约关联」开始");
        \DB::update("update kdgx_fpdx_deed set way = 1, `way_id` = `ack` where `type`=0 and `way_id` is null ");
        \DB::update("update kdgx_fpdx_deed set way = 0, `way_id` = `ack` where `type` != 0 and `way_id` is null ");
        dump("「修正旧数据的邀请-契约关联」开始");
    }
}
