id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->unsignedInteger('links_total')->default(0); $table->unsignedInteger('clicks_total')->default(0); $table->string('status', 32)->default('active'); $table->timestamps(); }); Schema::create('short_links', function (Blueprint $table) { $table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->string('slug', 32)->unique(); $table->string('label')->nullable(); $table->text('destination_url'); $table->boolean('is_active')->default(true); $table->unsignedInteger('clicks_total')->default(0); $table->unsignedInteger('unique_clicks_total')->default(0); $table->timestamp('last_clicked_at')->nullable(); $table->timestamp('expires_at')->nullable(); $table->timestamps(); $table->index(['user_id', 'created_at']); }); Schema::create('link_transactions', function (Blueprint $table) { $table->id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->foreignId('link_wallet_id')->constrained('link_wallets')->cascadeOnDelete(); $table->foreignId('short_link_id')->nullable()->constrained('short_links')->nullOnDelete(); $table->string('type', 16); $table->decimal('amount_ghs', 10, 4); $table->decimal('balance_after_ghs', 12, 4)->nullable(); $table->string('reference', 64)->unique(); $table->string('status', 32)->default('completed'); $table->string('description')->nullable(); $table->json('metadata')->nullable(); $table->timestamps(); }); Schema::create('link_clicks', function (Blueprint $table) { $table->id(); $table->foreignId('short_link_id')->constrained('short_links')->cascadeOnDelete(); $table->string('ip_hash', 64)->nullable(); $table->string('user_agent', 512)->nullable(); $table->string('referer', 512)->nullable(); $table->string('country', 2)->nullable(); $table->boolean('is_unique')->default(false); $table->timestamp('clicked_at'); $table->timestamps(); $table->index(['short_link_id', 'clicked_at']); }); } public function down(): void { Schema::dropIfExists('link_clicks'); Schema::dropIfExists('link_transactions'); Schema::dropIfExists('short_links'); Schema::dropIfExists('link_wallets'); } };