From ac74ab489dd82bef8b6c09022afcaf0219284063 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 13 Nov 2023 22:33:23 +0100 Subject: [PATCH] Migration: Fix worklog times and schedule shift type --- db/migrations/2020_09_07_000000_create_worklogs_table.php | 7 ++++--- ...000000_add_name_minutes_and_timestamps_to_schedules.php | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/db/migrations/2020_09_07_000000_create_worklogs_table.php b/db/migrations/2020_09_07_000000_create_worklogs_table.php index 7a078e1e..cc6e2f4e 100644 --- a/db/migrations/2020_09_07_000000_create_worklogs_table.php +++ b/db/migrations/2020_09_07_000000_create_worklogs_table.php @@ -37,6 +37,7 @@ class CreateWorklogsTable extends Migration ->get(); foreach ($previousRecords as $previousRecord) { + $worked_at = Carbon::createFromTimestamp($previousRecord->work_timestamp); $created_at = Carbon::createFromTimestamp($previousRecord->created_timestamp); $this->schema->getConnection() ->table('worklogs') @@ -44,7 +45,7 @@ class CreateWorklogsTable extends Migration 'id' => $previousRecord->id, 'user_id' => $previousRecord->user_id, 'creator_id' => $previousRecord->created_user_id, - 'worked_at' => $previousRecord->work_timestamp, + 'worked_at' => $worked_at, 'hours' => $previousRecord->work_hours, 'comment' => $previousRecord->comment, 'created_at' => $created_at, @@ -87,11 +88,11 @@ class CreateWorklogsTable extends Migration ->insert([ 'id' => $record->id, 'user_id' => $record->user_id, - 'work_timestamp' => $record->worked_at->timestamp, + 'work_timestamp' => Carbon::createFromFormat('Y-m-d', $record->worked_at)->timestamp, 'work_hours' => $record->hours, 'comment' => $record->comment, 'created_user_id' => $record->creator_id, - 'created_timestamp' => $record->created_at->timestamp, + 'created_timestamp' => Carbon::createFromFormat('Y-m-d H:i:s', $record->created_at)->timestamp, ]); } diff --git a/db/migrations/2020_11_20_000000_add_name_minutes_and_timestamps_to_schedules.php b/db/migrations/2020_11_20_000000_add_name_minutes_and_timestamps_to_schedules.php index 923457f0..c9aab649 100644 --- a/db/migrations/2020_11_20_000000_add_name_minutes_and_timestamps_to_schedules.php +++ b/db/migrations/2020_11_20_000000_add_name_minutes_and_timestamps_to_schedules.php @@ -21,7 +21,7 @@ class AddNameMinutesAndTimestampsToSchedules extends Migration $this->schema->table('schedules', function (Blueprint $table): void { $table->string('name')->default('')->after('id'); - $table->integer('shift_type')->default(0)->after('name'); + $table->unsignedInteger('shift_type')->default(0)->after('name'); $table->integer('minutes_before')->default(0)->after('shift_type'); $table->integer('minutes_after')->default(0)->after('minutes_before'); $table->timestamps(); @@ -36,7 +36,7 @@ class AddNameMinutesAndTimestampsToSchedules extends Migration $this->schema->table('schedules', function (Blueprint $table): void { $table->string('name')->default(null)->change(); - $table->integer('shift_type')->default(null)->change(); + $table->unsignedInteger('shift_type')->default(null)->change(); $table->integer('minutes_before')->default(null)->change(); $table->integer('minutes_after')->default(null)->change(); });