Add coupon fraud context and analytics tracking
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-02 23:31:26 +01:00
parent 75d862748b
commit 41ed682fbe
16 changed files with 461 additions and 21 deletions

View File

@@ -0,0 +1,30 @@
<?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('checkout_sessions', function (Blueprint $table) {
$table->string('ip_address', 45)->nullable()->after('provider_metadata');
$table->string('device_id', 64)->nullable()->after('ip_address');
$table->text('user_agent')->nullable()->after('device_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('checkout_sessions', function (Blueprint $table) {
$table->dropColumn(['user_agent', 'device_id', 'ip_address']);
});
}
};

View File

@@ -0,0 +1,35 @@
<?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('coupon_redemptions', function (Blueprint $table) {
$table->string('ip_address', 45)->nullable()->after('failure_reason');
$table->string('device_id', 64)->nullable()->after('ip_address');
$table->text('user_agent')->nullable()->after('device_id');
$table->index(['ip_address', 'created_at'], 'coupon_redemptions_ip_time_idx');
$table->index(['device_id', 'created_at'], 'coupon_redemptions_device_time_idx');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('coupon_redemptions', function (Blueprint $table) {
$table->dropIndex('coupon_redemptions_ip_time_idx');
$table->dropIndex('coupon_redemptions_device_time_idx');
$table->dropColumn(['user_agent', 'device_id', 'ip_address']);
});
}
};