Add coupon fraud context and analytics tracking
This commit is contained in:
@@ -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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user