mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
attendance retroactive increment total_days
This commit is contained in:
@@ -29,6 +29,7 @@ return new class extends Migration
|
||||
|
||||
Schema::table($tableName, function (Blueprint $table) {
|
||||
$table->unique(['torrent', 'peer_id', 'ip']);
|
||||
$table->index('peer_id');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$sql = "update attendance,attendance_logs set attendance.total_days = attendance.total_days + (select count(*) from attendance_logs where uid = attendance.uid and is_retroactive = 1)";
|
||||
\Illuminate\Support\Facades\DB::update($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user