This commit is contained in:
ct
2025-07-16 15:49:30 +08:00
parent d4c5fb5589
commit 6c8a69173e
24 changed files with 594 additions and 64 deletions

View File

@@ -24,7 +24,6 @@ public function up(): void
$table->enum('content_type', ['meme', 'background']);
$table->unsignedBigInteger('content_id');
$table->string('content_name');
$table->text('search_query')->nullable();
$table->enum('selection_method', ['search', 'browse', 'featured', 'recent']);
// Timestamps

View File

@@ -25,8 +25,6 @@ public function up(): void
$table->unsignedBigInteger('meme_media_id')->nullable();
$table->unsignedBigInteger('background_media_id')->nullable();
$table->json('caption_texts');
$table->enum('export_format', ['mov', 'webm', 'gif', 'webp']);
$table->enum('export_quality', ['standard', 'premium'])->default('standard');
$table->enum('export_status', ['initiated', 'processing', 'completed', 'failed'])->default('initiated');
$table->text('error_message')->nullable();
@@ -43,7 +41,6 @@ public function up(): void
// Indexes
$table->index(['device_id', 'action_at']);
$table->index(['export_status', 'action_at']);
$table->index(['export_format', 'action_at']);
$table->index('platform');
});
}

View File

@@ -28,15 +28,8 @@ public function up(): void
*/
public function down(): void
{
Schema::table('export_tokens', function (Blueprint $table) {
// Drop foreign key constraint
$table->dropForeign(['user_id']);
// Make user_id NOT nullable again
$table->unsignedBigInteger('user_id')->nullable(false)->change();
// Add foreign key back without nullable
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
// This migration made user_id nullable to support anonymous users
// Reversing this would break existing anonymous tokens, so we'll leave it nullable
// and just update the foreign key constraint if needed
}
};

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('export_tokens', function (Blueprint $table) {
$table->json('metadata')->nullable()->after('credits_reserved');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('export_tokens', function (Blueprint $table) {
$table->dropColumn('metadata');
});
}
};

View File

@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('track_saves', function (Blueprint $table) {
$table->id();
// Common fields
$table->string('device_id');
$table->text('user_agent')->nullable();
$table->string('ip_address')->nullable();
$table->enum('platform', ['web', 'ios', 'android'])->default('web');
// Save action fields
$table->unsignedBigInteger('meme_id')->nullable();
$table->unsignedBigInteger('meme_media_id')->nullable();
$table->unsignedBigInteger('background_media_id')->nullable();
$table->json('caption_texts');
$table->boolean('is_premium_export')->default(false);
// Timestamps
$table->timestamp('action_at');
$table->timestamps();
// Indexes
$table->index(['device_id', 'action_at']);
$table->index(['meme_id', 'action_at']);
$table->index(['meme_media_id', 'action_at']);
$table->index(['background_media_id', 'action_at']);
$table->index(['is_premium_export', 'action_at']);
$table->index('platform');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('track_saves');
}
};