add set scheduling api
This commit is contained in:
parent
bdb266746d
commit
98ae9bf088
20 changed files with 935 additions and 1 deletions
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('schedules', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')
|
||||
->constrained('users')
|
||||
->restrictOnDelete();
|
||||
$table->foreignId('set_id')
|
||||
->constrained('sets')
|
||||
->restrictOnDelete();
|
||||
$table->string('element_kind');
|
||||
$table->date('start_date');
|
||||
$table->date('target_date');
|
||||
$table->index(['user_id', 'id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('schedules');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create(
|
||||
'schedule_assignments',
|
||||
function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('schedule_id')
|
||||
->constrained('schedules')
|
||||
->cascadeOnDelete();
|
||||
$table->foreignId('element_id')
|
||||
->constrained('elements')
|
||||
->restrictOnDelete();
|
||||
$table->date('scheduled_date');
|
||||
$table->unsignedInteger('position');
|
||||
$table->unique(['schedule_id', 'element_id']);
|
||||
$table->unique(['schedule_id', 'position']);
|
||||
$table->index([
|
||||
'schedule_id',
|
||||
'scheduled_date',
|
||||
'position',
|
||||
]);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('schedule_assignments');
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue