PostgreSQL Support (#4486)
Co-authored-by: Matthew Penner <matthew@pterodactyl.io>
This commit is contained in:
parent
21613fa602
commit
3bf5a71802
223 changed files with 912 additions and 1052 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
|
@ -10,40 +11,40 @@ class TransferOldTasksToNewScheduler extends Migration
|
|||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
public function up(): void
|
||||
{
|
||||
$tasks = DB::table('tasks_old')->get();
|
||||
DB::transaction(function () {
|
||||
$tasks = DB::table('tasks_old')->get();
|
||||
|
||||
DB::beginTransaction();
|
||||
$tasks->each(function ($task) {
|
||||
$schedule = DB::table('schedules')->insertGetId([
|
||||
'server_id' => $task->server_id,
|
||||
'name' => null,
|
||||
'cron_day_of_week' => $task->day_of_week,
|
||||
'cron_day_of_month' => $task->day_of_month,
|
||||
'cron_hour' => $task->hour,
|
||||
'cron_minute' => $task->minute,
|
||||
'is_active' => (bool) $task->active,
|
||||
'is_processing' => false,
|
||||
'last_run_at' => $task->last_run,
|
||||
'next_run_at' => $task->next_run,
|
||||
'created_at' => $task->created_at,
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
$tasks->each(function ($task) {
|
||||
$schedule = DB::table('schedules')->insertGetId([
|
||||
'server_id' => $task->server_id,
|
||||
'name' => null,
|
||||
'cron_day_of_week' => $task->day_of_week,
|
||||
'cron_day_of_month' => $task->day_of_month,
|
||||
'cron_hour' => $task->hour,
|
||||
'cron_minute' => $task->minute,
|
||||
'is_active' => (bool) $task->active,
|
||||
'is_processing' => false,
|
||||
'last_run_at' => $task->last_run,
|
||||
'next_run_at' => $task->next_run,
|
||||
'created_at' => $task->created_at,
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
|
||||
DB::table('tasks')->insert([
|
||||
'schedule_id' => $schedule,
|
||||
'sequence_id' => 1,
|
||||
'action' => $task->action,
|
||||
'payload' => $task->data,
|
||||
'time_offset' => 0,
|
||||
'is_queued' => false,
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
DB::table('tasks')->insert([
|
||||
'schedule_id' => $schedule,
|
||||
'sequence_id' => 1,
|
||||
'action' => $task->action,
|
||||
'payload' => $task->data,
|
||||
'time_offset' => 0,
|
||||
'is_queued' => false,
|
||||
'updated_at' => Carbon::now()->toDateTimeString(),
|
||||
'created_at' => Carbon::now()->toDateTimeString(),
|
||||
]);
|
||||
|
||||
DB::table('tasks_old')->delete($task->id);
|
||||
DB::commit();
|
||||
DB::table('tasks_old')->delete($task->id);
|
||||
});
|
||||
});
|
||||
|
||||
Schema::dropIfExists('tasks_old');
|
||||
|
@ -52,7 +53,7 @@ class TransferOldTasksToNewScheduler extends Migration
|
|||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down()
|
||||
public function down(): void
|
||||
{
|
||||
Schema::create('tasks_old', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue