完善功能
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?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('ad_slots', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('key')->unique();
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedSmallInteger('max_items')->default(3);
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['is_active', 'sort']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ad_slots');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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('ads', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('ad_slot_id')->constrained('ad_slots')->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->string('image')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('link_url')->nullable();
|
||||
$table->string('link_target')->default('_blank');
|
||||
$table->foreignId('product_id')->nullable()->constrained('products')->nullOnDelete();
|
||||
$table->dateTime('starts_at')->nullable();
|
||||
$table->dateTime('ends_at')->nullable();
|
||||
$table->unsignedInteger('sort')->default(0);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->unsignedInteger('view_count')->default(0);
|
||||
$table->unsignedInteger('click_count')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['ad_slot_id', 'is_active', 'sort']);
|
||||
$table->index(['starts_at', 'ends_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ads');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user