feat: add type category

This commit is contained in:
2026-06-11 09:48:59 +03:30
parent a1a858abbf
commit 934a3884ad
3 changed files with 79 additions and 3 deletions
@@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('categories', function (Blueprint $table) {
// General category type: media | playlist | breathing_template
$table->string('type')->default('media')->after('name')->index();
});
// Existing categories were used for media content.
DB::table('categories')->update(['type' => 'media']);
// Name is unique per type (same name may exist for media and playlist).
Schema::table('categories', function (Blueprint $table) {
$table->dropUnique('categories_name_unique');
$table->unique(['name', 'type']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('categories', function (Blueprint $table) {
$table->dropUnique(['name', 'type']);
$table->unique('name');
$table->dropColumn('type');
});
}
};