<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class Docters extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('docters', function (Blueprint $table) {
            // 修改docters字段
//            $table->integer('user_id')->comment('用户表关联id');
//            $table->string('password',50)->nullable()->comment('密码');
//            $table->integer('is_then')->nullable()->comment('是否认证：0=未认证；1=认证');
//            $table->string('practice',200)->nullable()->comment('医生照片和执业证书，号分开');
//            $table->string('card_photo',200)->nullable()->comment('身份证正反面，号分开');
//            $table->string('is_quail',200)->nullable()->comment('照片和资格证书，号分开');
//            $table->integer('card_id',20)->nullable()->comment('身份证号');
        });

        // 创建意见详情
/*        Schema::create('suggests_detail', function (Blueprint $table) {
            $table->integer('suggest_id')->comment('suggest表主键');
            $table->string('supplement_reason',2000)->comment('补充原因');
            $table->string('supplement_content',2000)->comment('补充建议');
            $table->timestamps();
        });*/

        // 修改订单表
        Schema::table('orders', function (Blueprint $table) {
            //添加接单时间
//            $table->integer('receiving_time')->comment('接单时间');
        });

        // 用户消息表
        Schema::table('user_messages', function (Blueprint $table) {
            //添加医生id
//            $table->integer('docter_id')->after('user_id')->comment('医生ID');
        });

        // 医生消息表
        Schema::create('docter_messages', function (Blueprint $table) {
//            $table->bigIncrements('id');
//            $table->integer('user_id')->comment("用户ID");
//            $table->integer('docter_id')->comment("医生ID");
//            $table->tinyInteger('status')->comment("状态(1.未读 2.已读)");
//            $table->tinyInteger('type')->comment("类型(1.图文订单 2.电话订单 3.预约订单 4.评价通知 5.系统通知)");
//            $table->integer('relation_id')->comment("关联ID(发出消息操作关联的表的id，比如：医生结束消息时，就该关联意见单ID,因为用户点击消息会进入看意见单)");
//            $table->string('content',500)->comment("消息内容");
//            $table->timestamps();
        });


        // 童话记录表
    /*    Schema::create('call_logs', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('order_id')->nullable()->comment("订单表ID");
            $table->integer('dial_time')->nullable()->comment("拨打时间");
            $table->integer('dialend_time')->nullable()->comment("结束时间");
            $table->integer('talk_time')->nullable()->comment("通话时长");
            $table->timestamps();
        });*/


        // 医生时间段服务设置
  /*      Schema::create('docter_times', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('docter_id')->comment("医生id");
            $table->decimal('base_price',8,2)->nullable()->comment("基础价格");
            $table->decimal('step_price',8,2)->nullable()->comment("步进价格");
            $table->string('service_time',2000)->nullable()->comment("服务时间(00点到24点的索引)");
            $table->integer('person')->nullable()->comment("服务人次");
            $table->integer('type')->nullable()->comment("类型（1=电话咨询，2=图文咨询，3=门诊预约,4=疫苗接种预约,5=儿保预约,6=服务包,7=充值）");
            $table->integer('relation_id')->nullable()->comment("关联id（为门诊预约时，关联机构id）");
            $table->timestamps();
        });*/

        // user表添加字段
        Schema::table('users', function (Blueprint $table) {
//            $table->string('remark',200)->nullable()->comment('用户备注');
        });

        // 医生用户关联表，暂时没用到 （可以作为拓展用）
        Schema::create('docter_user', function (Blueprint $table) {
//            $table->bigIncrements('id');
//            $table->integer('docter_id')->comment('医生表主键');
//            $table->integer('user_id')->comment('用户表主键');
//            $table->timestamps();
        });

        //医生机构表加字段
        Schema::table('docter_organization', function (Blueprint $table) {
            //添加医生id
//            $table->integer('offices_id')->nullable()->after('organization_id')->comment('机构ID');
//            $table->integer('qualifications_id')->nullable()->after('offices_id')->comment('资质id');
//            $table->integer('state')->nullable()->after('qualifications_id')->comment('审核状态(0=待审核，1=审核通过，2=审核拒绝)');
        });

        // 排班具体时间表
        Schema::table('schedule_periods', function (Blueprint $table) {
            //添加医生id
            $table->integer('type')->nullable()->after('docter_id')->comment('下单时间段（1=早上，2=下午，3=晚上）');
        });


        // 意见
        Schema::table('suggests', function (Blueprint $table) {
            //添加医生id
            $table->integer('patient_id')->nullable()->after('user_id')->comment('患者id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('docters', function (Blueprint $table) {
            $table->dropColumn('user_id');
            $table->dropColumn('receiving_time');
        });

        Schema::dropIfExists('suggests_detail');

        Schema::table('orders', function (Blueprint $table) {
            //删除接单时间
            $table->dropColumn('receiving_time');
        });

        Schema::dropIfExists('docter_messages');

//        Schema::dropIfExists('call_logs');

//        Schema::dropIfExists('docter_times');

        Schema::table('user', function (Blueprint $table) {

        });


        Schema::table('user_messages', function (Blueprint $table) {
            //
        });


        Schema::table('docter_organization', function (Blueprint $table) {
            //
        });

        Schema::table('schedule_periods', function (Blueprint $table) {
            //
        });

        Schema::table('suggests', function (Blueprint $table) {
                    //
        });

        Schema::dropIfExists('docter_user');

    }
}
