Fixed data type of project and task spend time

This commit is contained in:
Constantin Graf
2025-04-25 22:32:37 +02:00
parent f1a1d2a266
commit ef9f353047
3 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('projects', function (Blueprint $table): void {
$table->bigInteger('spent_time')->unsigned()->default(0)->change();
});
Schema::table('tasks', function (Blueprint $table): void {
$table->bigInteger('spent_time')->unsigned()->default(0)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('projects', function (Blueprint $table): void {
$table->integer('spent_time')->unsigned()->default(0)->change();
});
Schema::table('tasks', function (Blueprint $table): void {
$table->integer('spent_time')->unsigned()->default(0)->change();
});
}
};

View File

@@ -185,4 +185,19 @@ class ProjectModelTest extends ModelTestAbstract
// Assert
$this->assertFalse($isArchived);
}
public function test_project_can_store_big_amounts_of_spent_time(): void
{
// Arrange
$project = Project::factory()->create();
$spentTime = 100 * 365 * 24 * 60 * 60; // 100 years in seconds
// Act
$project->spent_time = $spentTime;
$project->save();
$project->refresh();
// Assert
$this->assertSame($spentTime, $project->spent_time);
}
}

View File

@@ -114,4 +114,19 @@ class TaskModelTest extends ModelTestAbstract
// Assert
$this->assertFalse($task->is_done);
}
public function test_task_can_store_big_amounts_of_spent_time(): void
{
// Arrange
$task = Task::factory()->create();
$spentTime = 100 * 365 * 24 * 60 * 60; // 100 years in seconds
// Act
$task->spent_time = $spentTime;
$task->save();
$task->refresh();
// Assert
$this->assertSame($spentTime, $task->spent_time);
}
}