clrghouz/database/migrations/2023_06_23_170537_unique_filenames.php

37 lines
906 B
PHP
Raw Permalink 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.
*
* @return void
*/
// delete from files where id in (130,110,25,49,50,51,52,53,73,105,4,44,60,83,85,63,88,90,66,68,70,72,75,78,80,123,124,127,1,102,104,107,109,113,115,117,2,119)
public function up()
{
DB::statement('ALTER TABLE files RENAME COLUMN file to name');
DB::statement('ALTER TABLE files RENAME COLUMN lfile to lname');
Schema::table('files',function (Blueprint $table) {
$table->unique(['filearea_id','name']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('files',function (Blueprint $table) {
$table->dropUnique(['filearea_id','name']);
});
}
};