Files
mytodos/database/migrations/2026_09_18_045605_create_folders_table.php
ecdown 1e8ae3d1e5
tests / ci (push) Canceled after 0s
first commit;
2026-09-17 23:01:26 -07:00

33 lines
796 B
PHP

<?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('folders', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->foreignId('parent_id')->nullable()->constrained('folders')->cascadeOnDelete();
$table->timestamps();
$table->index(['user_id', 'parent_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('folders');
}
};