mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-14 06:25:28 +00:00
kick forever
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$cutoff = now()->subHour();
|
||||
|
||||
DB::table('players')
|
||||
->where(function ($query) use ($cutoff): void {
|
||||
$query->whereNotNull('inactive_at')
|
||||
->orWhere('last_seen_at', '<=', $cutoff)
|
||||
->orWhere(function ($query) use ($cutoff): void {
|
||||
$query->whereNull('last_seen_at')
|
||||
->where('created_at', '<=', $cutoff);
|
||||
});
|
||||
})
|
||||
->delete();
|
||||
|
||||
Schema::table('players', function (Blueprint $table): void {
|
||||
$table->dropColumn('inactive_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('players', function (Blueprint $table): void {
|
||||
$table->timestamp('inactive_at')->nullable()->after('last_seen_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user