added tracks and perfomers tables, fixed queries
This commit is contained in:
@@ -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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user