feat: implement Attachment domain for file storage and integrate into Tenant service for logo management

This commit is contained in:
2026-06-29 09:43:46 -03:00
parent 67bc9e6cb4
commit b0508d79b3
9 changed files with 2 additions and 179 deletions

View File

@@ -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');
});

View File

@@ -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']);
});
}
};