You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.5 KiB

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('demands', function (Blueprint $table) {
$table->id();
$table->foreignId('teacher_id')
->nullable()
->constrained('teachers')
->nullOnDelete();
$table->foreignId('type_dict_item_id')
->constrained('dict_items')
->restrictOnDelete()
->comment('需求类型,字典 demand_type');
$table->foreignId('status_dict_item_id')
->constrained('dict_items')
->restrictOnDelete()
->comment('处理状态,字典 demand_status');
$table->string('title', 255);
$table->text('content')->comment('需求描述');
$table->string('contact_name', 64)->nullable()->comment('提交人/姓名');
$table->string('company', 128)->nullable()->comment('公司');
$table->timestamp('submitted_at')->nullable();
$table->unsignedBigInteger('miniapp_user_id')->nullable()->comment('小程序用户,预留');
$table->timestamps();
$table->softDeletes();
$table->index(['type_dict_item_id', 'status_dict_item_id']);
$table->index(['teacher_id', 'submitted_at']);
});
Schema::create('demand_handle_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('demand_id')->constrained('demands')->cascadeOnDelete();
$table->foreignId('admin_user_id')
->nullable()
->constrained('admin_users')
->nullOnDelete();
$table->foreignId('status_dict_item_id')
->constrained('dict_items')
->restrictOnDelete()
->comment('本次处理后的状态,字典 demand_status');
$table->text('content')->comment('跟进内容');
$table->string('next_plan', 255)->nullable()->comment('下次跟进计划');
$table->date('next_follow_date')->nullable();
$table->date('handled_at')->comment('跟进日期');
$table->timestamps();
$table->index(['demand_id', 'handled_at']);
});
}
public function down(): void
{
Schema::dropIfExists('demand_handle_logs');
Schema::dropIfExists('demands');
}
};