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.
35 lines
1.3 KiB
35 lines
1.3 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('banners', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('type', 16)->comment('course=课程 activity=活动 custom=自定义');
|
|
$table->unsignedBigInteger('course_id')->nullable();
|
|
$table->unsignedBigInteger('activity_id')->nullable();
|
|
$table->string('title', 255)->nullable()->comment('自定义标题');
|
|
$table->string('cover_url', 512)->nullable()->comment('自定义封面图 URL');
|
|
$table->longText('content_html')->nullable()->comment('自定义富文本内容');
|
|
$table->unsignedInteger('sort')->default(0);
|
|
$table->unsignedTinyInteger('status')->default(1)->comment('1=启用 0=停用');
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->foreign('course_id')->references('id')->on('courses')->nullOnDelete();
|
|
$table->foreign('activity_id')->references('id')->on('activities')->nullOnDelete();
|
|
$table->index(['type', 'status', 'sort']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('banners');
|
|
}
|
|
};
|