feat(scanner): scope login tickets scanning and history by event
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('scan_attempts', function (Blueprint $table): void {
|
||||
$table->foreignId('event_id')->nullable()->constrained('events')->nullOnDelete();
|
||||
$table->index(['scanner_user_id', 'event_id']);
|
||||
});
|
||||
DB::table('scan_attempts')->update([
|
||||
'event_id' => DB::raw('(SELECT tickets.event_id FROM tickets WHERE tickets.id = scan_attempts.ticket_id)'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('scan_attempts', function (Blueprint $table): void {
|
||||
$table->dropIndex(['scanner_user_id', 'event_id']);
|
||||
$table->dropConstrainedForeignId('event_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user