Update
This commit is contained in:
@@ -13,22 +13,22 @@ public function up(): void
|
||||
{
|
||||
Schema::create('tracking_searches', 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');
|
||||
|
||||
|
||||
// Search-specific fields
|
||||
$table->enum('search_type', ['meme', 'background']);
|
||||
$table->text('search_query');
|
||||
$table->json('search_filters')->nullable();
|
||||
|
||||
|
||||
// Timestamps
|
||||
$table->timestamp('action_at');
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
// Indexes
|
||||
$table->index(['device_id', 'action_at']);
|
||||
$table->index(['search_type', 'action_at']);
|
||||
|
||||
@@ -13,24 +13,24 @@ public function up(): void
|
||||
{
|
||||
Schema::create('tracking_content_selections', 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');
|
||||
|
||||
|
||||
// Content selection fields
|
||||
$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
|
||||
$table->timestamp('action_at');
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
// Indexes
|
||||
$table->index(['device_id', 'action_at']);
|
||||
$table->index(['content_type', 'content_id']);
|
||||
|
||||
@@ -13,13 +13,13 @@ public function up(): void
|
||||
{
|
||||
Schema::create('tracking_exports', 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');
|
||||
|
||||
|
||||
// Export-specific fields
|
||||
$table->unsignedBigInteger('meme_id')->nullable();
|
||||
$table->unsignedBigInteger('meme_media_id')->nullable();
|
||||
@@ -29,17 +29,17 @@ public function up(): void
|
||||
$table->enum('export_quality', ['standard', 'premium'])->default('standard');
|
||||
$table->enum('export_status', ['initiated', 'processing', 'completed', 'failed'])->default('initiated');
|
||||
$table->text('error_message')->nullable();
|
||||
|
||||
|
||||
// Timestamps
|
||||
$table->timestamp('action_at');
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
// Foreign key constraints
|
||||
$table->foreign('meme_id')->references('id')->on('memes')->onDelete('set null');
|
||||
$table->foreign('meme_media_id')->references('id')->on('meme_medias')->onDelete('set null');
|
||||
$table->foreign('background_media_id')->references('id')->on('background_medias')->onDelete('set null');
|
||||
|
||||
|
||||
// Indexes
|
||||
$table->index(['device_id', 'action_at']);
|
||||
$table->index(['export_status', 'action_at']);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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) {
|
||||
// Drop foreign key constraint first
|
||||
$table->dropForeign(['user_id']);
|
||||
|
||||
// Make user_id nullable
|
||||
$table->unsignedBigInteger('user_id')->nullable()->change();
|
||||
|
||||
// Add foreign key back with nullable support
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
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');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user