added tracks and perfomers tables, fixed queries

This commit is contained in:
2026-06-17 12:04:26 +03:00
parent 23b5b4a9b2
commit 4ea8ce6569
7 changed files with 190 additions and 12 deletions
@@ -0,0 +1,29 @@
<?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('performers', function (Blueprint $table) {
$table->id(); // id (bigint unsigned, auto-increment)
$table->string('name'); // name (имя исполнителя / название группы)
$table->timestamps(); // created_at и updated_at
$table->softDeletes(); // deleted_at (для мягкого удаления)
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('performers');
}
};
@@ -0,0 +1,36 @@
<?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('tracks', function (Blueprint $table) {
$table->id(); // id (bigint unsigned, auto-increment)
$table->string('name'); // name (varchar 255)
$table->unsignedInteger('length'); // length (длительность трека в секундах)
// performer_id (внешний ключ, связываем с таблицей performers)
$table->foreignId('performer_id')
->constrained('performers')
->onDelete('cascade'); // если удалить исполнителя, удалятся и его треки
$table->timestamps(); // created_at и updated_at
$table->softDeletes(); // deleted_at (для мягкого удаления)
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tracks');
}
};