2025_06_11_140358_create_tickets_table.php 1.8 KB
<?php

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

class CreateTicketsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('gl_tickets', function (Blueprint $table) {
            $table->id();
            $table->foreignId('project_id')->constrained('gl_ticket_projects')->onDelete('cascade')->comment('项目ID');
            $table->string('title')->nullable()->comment('工单类型,工单标题');
            $table->longText('content')->comment('工单图文描述');
            $table->json('files')->nullable()->comment('附件');
            $table->integer('status')->index()->default(0)->comment('工单状态,0:待处理, 1:处理中,2:已完成, 3:已关闭');
            $table->integer('submit_side')->default(1)->index()->comment('提交方,1: A端, 2: B端');
            $table->string('submit_username')->nullable()->comment('提交人姓名,B端在企微群提交时,留个姓名即可');
            $table->integer('submit_user_id')->default(0)->index()->comment('A端提交时,提交人 gl_manage ID');
            $table->timestamp('end_at')->nullable()->comment('结束时间,工单状态为已完成或已关闭时有值');
            $table->longText('reply')->nullable()->comment('回复内容,审核意见,可以为空');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `gl_tickets` comment '工单表,注意:B端,A端都会提工单'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('gl_tickets');
    }
}