clrghouz/database/migrations/2023_09_22_233947_file_tweeks.php

35 lines
797 B
PHP
Raw Normal View History

<?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('files', function (Blueprint $table) {
$table->dropUnique(['filearea_id','name']);
$table->string('replaces')->nullable();
});
DB::statement("CREATE UNIQUE INDEX files_active ON files (filearea_id, name) WHERE deleted_at IS NULL");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
DB::statement("DROP INDEX files_active");
Schema::table('files', function (Blueprint $table) {
$table->unique(['filearea_id','name']);
$table->dropColumn('replaces');
});
}
};