<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Spatie\Permission\Models\Permission;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Create new My Folder permissions
        $myFolderPermissions = [
            'Create My Folder',
            'View My Folder', 
            'Edit My Folder',
            'Delete My Folder',
            'Share My Folder',
            'Upload My Files',
            'Download My Files',
            'View My File Metadata',
            'Search My Files',
            'Delete My Files'
        ];

        foreach ($myFolderPermissions as $permission) {
            Permission::create(['name' => $permission]);
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Remove My Folder permissions
        $myFolderPermissions = [
            'Create My Folder',
            'View My Folder',
            'Edit My Folder', 
            'Delete My Folder',
            'Share My Folder',
            'Upload My Files',
            'Download My Files',
            'View My File Metadata',
            'Search My Files',
            'Delete My Files'
        ];

        foreach ($myFolderPermissions as $permission) {
            Permission::where('name', $permission)->delete();
        }
    }
};
