Add multi-week workout programs
A Workout was a single flat session with no way to schedule several across weeks/days as a structured plan (e.g. Push/Pull/Legs over 4 weeks) - every user started from a blank builder each time, and there was no template concept at all. Adds a Program (title, description, week count) that Workouts can optionally belong to via nullable program_id/week_number/day_number columns, reusing all existing workout and session-tracking infrastructure rather than building a parallel system. The program show page lays out the schedule week by week and derives progress (completed vs total) from the user's existing WorkoutSession completions - no new enrollment/progress-tracking concept needed. Deleting a program unschedules its workouts (nullOnDelete) rather than destroying them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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('programs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->unsignedTinyInteger('weeks')->default(4);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('programs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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::table('workouts', function (Blueprint $table) {
|
||||
$table->foreignId('program_id')->nullable()->after('user_id')->constrained()->nullOnDelete();
|
||||
$table->unsignedTinyInteger('week_number')->nullable()->after('program_id');
|
||||
$table->unsignedTinyInteger('day_number')->nullable()->after('week_number');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('workouts', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('program_id');
|
||||
$table->dropColumn(['week_number', 'day_number']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user