feat: history and calculate needs for user
CI / 🧪 Tests Laravel (push) Failing after 2m18s
CI / 🐳 Build & Push Images (push) Has been skipped

This commit is contained in:
2026-08-14 12:45:37 +02:00
parent ea5a5737ec
commit 69372a49ed
51 changed files with 2226 additions and 305 deletions
@@ -19,20 +19,17 @@ return new class extends Migration
$table->string('password');
$table->string('role')->default('user');
$table->text('bio')->nullable();
$table->integer('height')->nullable();
$table->unsignedSmallInteger('height')->nullable();
$table->decimal('target_weight', 5, 2)->nullable();
$table->date('date_of_birth')->nullable();
$table->string('sex')->default('unknown');
$table->string('physical_activity_level')->default('sedentary');
$table->string('weight_goal')->default('lose_weight');
$table->string('pace_preference')->default('slow');
$table->string('sex')->nullable();
$table->string('physical_activity_level')->nullable();
$table->string('weight_goal')->nullable();
$table->string('pace_preference')->nullable();
$table->string('locale', 8)->default('en')->after('email');
$table->string('avatar_url', 2048)->nullable();
// Goals
$table->unsignedInteger('daily_calorie_goal')->default(2000)->after('avatar_url');
$table->decimal('daily_protein_goal', 8, 2)->default(120)->after('daily_calorie_goal');
$table->decimal('daily_carbs_goal', 8, 2)->default(250)->after('daily_protein_goal');
$table->decimal('daily_fats_goal', 8, 2)->default(70)->after('daily_carbs_goal');
$table->timestampTz('onboarding_completed_at')->nullable()->index();
$table->timestampTz('nutrition_estimate_accepted_at')->nullable();
// Moderation
$table->timestamp('suspended_at')->nullable()->after('deleted_at')->index();
$table->ulid('suspended_by')->nullable()->after('suspended_at')->index();
@@ -0,0 +1,44 @@
<?php
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::create('nutrition_plans', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('user_id')->constrained('users')->cascadeOnDelete();
$table->string('source', 32);
$table->string('formula_version', 64);
$table->unsignedInteger('calories');
$table->decimal('proteins', 8, 2);
$table->decimal('carbs', 8, 2);
$table->decimal('fats', 8, 2);
$table->unsignedInteger('resting_metabolism');
$table->unsignedInteger('maintenance_calories');
$table->decimal('calorie_adjustment_percent', 6, 4)->default(0);
$table->json('calculation_details');
$table->boolean('is_active')->default(true);
$table->timestampTz('effective_from');
$table->timestampTz('effective_until')->nullable();
$table->timestampsTz();
$table->index(['user_id', 'is_active']);
$table->index(['user_id', 'effective_from']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('nutrition_plans');
}
};
@@ -0,0 +1,33 @@
<?php
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::create('weight_entries', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('user_id')->constrained('users')->cascadeOnDelete();
$table->decimal('weight_kg', 5, 2);
$table->string('source', 32)->default('manual');
$table->timestampTz('measured_at');
$table->timestampsTz();
$table->index(['user_id', 'measured_at']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('weight_entries');
}
};
@@ -0,0 +1,49 @@
<?php
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::create('weekly_reviews', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('user_id')->constrained('users')->cascadeOnDelete();
$table->foreignUlid('nutrition_plan_id')->nullable()->constrained('nutrition_plans')->nullOnDelete();
$table->date('period_start');
$table->date('period_end');
$table->decimal('average_calories', 8, 2)->default(0);
$table->decimal('average_proteins', 8, 2)->default(0);
$table->decimal('average_carbs', 8, 2)->default(0);
$table->decimal('average_fats', 8, 2)->default(0);
$table->unsignedTinyInteger('logged_days_count')->default(0);
$table->unsignedTinyInteger('weight_entries_count')->default(0);
$table->decimal('weight_trend_kg', 5, 2)->nullable();
$table->decimal('target_weight_trend_kg', 5, 2)->nullable();
$table->string('status', 32);
$table->smallInteger('recommended_calorie_adjustment')->default(0);
$table->string('message_code', 80);
$table->json('metrics');
$table->timestampTz('generated_at');
$table->timestampTz('accepted_at')->nullable();
$table->foreignUlid('accepted_nutrition_plan_id')->nullable()->constrained('nutrition_plans')->nullOnDelete();
$table->timestampsTz();
$table->unique(['user_id', 'period_start']);
$table->index(['user_id', 'period_end']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('weekly_reviews');
}
};