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.
38 lines
1.5 KiB
38 lines
1.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('course_checkin_days', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('course_id')->constrained('courses')->cascadeOnDelete();
|
|
$table->date('teach_date')->comment('开课日(按 teach_start~end 逐日生成)');
|
|
$table->string('signin_code', 64)->comment('当日签到码,扫码/补签关联此日');
|
|
$table->timestamps();
|
|
$table->unique(['course_id', 'teach_date'], 'crs_chk_day_course_date_uq');
|
|
$table->unique('signin_code', 'crs_chk_day_code_uq');
|
|
});
|
|
|
|
Schema::create('course_signup_checkins', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('course_signup_id')->constrained('course_signups')->cascadeOnDelete();
|
|
$table->date('checkin_date');
|
|
$table->dateTime('checked_in_at')->nullable();
|
|
$table->timestamps();
|
|
$table->unique(['course_signup_id', 'checkin_date'], 'crs_signup_chk_date_uq');
|
|
$table->index(['checkin_date', 'checked_in_at'], 'crs_signup_chk_at_idx');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('course_signup_checkins');
|
|
Schema::dropIfExists('course_checkin_days');
|
|
}
|
|
};
|