feat: implement Attachment domain for file storage and integrate into Tenant service for logo management
This commit is contained in:
@@ -13,8 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('attachments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('attachable_type');
|
||||
$table->unsignedBigInteger('attachable_id');
|
||||
$table->uuid('key')->unique();
|
||||
$table->string('path');
|
||||
$table->string('filename');
|
||||
@@ -24,7 +22,6 @@ return new class extends Migration
|
||||
$table->unsignedBigInteger('size')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['attachable_type', 'attachable_id']);
|
||||
$table->index('type');
|
||||
$table->index('mime_type');
|
||||
});
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?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('attachments', function (Blueprint $table): void {
|
||||
$table->dropIndex(['attachable_type', 'attachable_id']);
|
||||
$table->dropColumn(['attachable_type', 'attachable_id']);
|
||||
});
|
||||
|
||||
Schema::create('attachable_attachments', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('attachable_type');
|
||||
$table->unsignedBigInteger('attachable_id');
|
||||
$table->foreignId('attachment_id')->constrained('attachments')->cascadeOnDelete();
|
||||
|
||||
$table->unique(['attachable_type', 'attachable_id', 'attachment_id'], 'attachable_attachments_unique');
|
||||
$table->index(['attachable_type', 'attachable_id'], 'attachable_attachments_attachable_index');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('attachable_attachments');
|
||||
|
||||
Schema::table('attachments', function (Blueprint $table): void {
|
||||
$table->string('attachable_type');
|
||||
$table->unsignedBigInteger('attachable_id');
|
||||
$table->index(['attachable_type', 'attachable_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user