feat: add imag_id to music

This commit is contained in:
2025-09-27 14:29:46 +03:30
parent 25e1ddd1f4
commit 436c7306b2
3 changed files with 60 additions and 13 deletions
@@ -0,0 +1,35 @@
<?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::table('music', function (Blueprint $table) {
$table->unsignedBigInteger('image_id')->nullable()->after('file_path');
// add foreign key constraint with cascade on delete set null
$table->foreign('image_id')
->references('id')
->on('images')
->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('music', function (Blueprint $table) {
$table->dropForeign(['image_id']);
$table->dropColumn('image_id');
});
}
};