Deploy Ladill Link / deploy (push) Successful in 1m26s
Let accounts organise links by promo or launch, attach or detach links, and view combined click totals from the sidebar.
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?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('campaigns', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
|
$table->string('name');
|
|
$table->text('description')->nullable();
|
|
$table->string('status', 20)->default('active')->index();
|
|
$table->timestamp('starts_at')->nullable();
|
|
$table->timestamp('ends_at')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->index(['user_id', 'status']);
|
|
});
|
|
|
|
Schema::table('short_links', function (Blueprint $table) {
|
|
$table->foreignId('campaign_id')->nullable()->after('user_id')->constrained('campaigns')->nullOnDelete();
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::table('short_links', function (Blueprint $table) {
|
|
$table->dropConstrainedForeignId('campaign_id');
|
|
});
|
|
|
|
Schema::dropIfExists('campaigns');
|
|
}
|
|
};
|