enforce element level hierarchy

This commit is contained in:
Yisroel Baum 2026-08-11 22:50:07 +03:00
parent 25495b6c4d
commit 99e1ba051c
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 80 additions and 44 deletions

View file

@ -10,18 +10,17 @@ return new class extends Migration
{
Schema::create('elements', function (Blueprint $table): void {
$table->id();
$table->foreignId('set_id')
->constrained('sets')
$table->foreignId('set_level_id')
->constrained('set_levels')
->restrictOnDelete();
$table->string('name');
$table->string('kind');
$table->foreignId('parent_element_id')
->nullable()
->constrained('elements')
->restrictOnDelete();
$table->unsignedInteger('position');
$table->index([
'set_id',
'set_level_id',
'parent_element_id',
'position',
]);