Enhancements to Tenant Warehouse Management in Platform

Introduction

The Reimpact platform is undergoing improvements to its multi-tenancy architecture, specifically focusing on tenant warehouse management. This involves refining database queries and updating tenant schemas for better isolation and data integrity.

The Problem

Previously, the GeneratedReportResource was incorrectly querying the company_id on tenant-specific warehouse tables. Since tenant tables are isolated by schema, company_id is redundant and shouldn't be included. Additionally, the declarant column was missing from the tenant warehouse migration, causing inconsistencies.

The Solution

The solution involves two key changes:

  1. Removing the unnecessary company_id from tenant warehouse queries within the GeneratedReportResource.
  2. Adding the missing declarant column to the tenant warehouse migration.

This ensures that tenant-specific queries are streamlined and accurate, aligning with the platform's multi-tenancy architecture.

Implementation

Here's an example of how the tenant warehouse migration might be updated to include the declarant column:

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddDeclarantToTenantWarehouses extends Migration
{
    public function up()
    {
        Schema::table('warehouses', function (Blueprint $table) {
            $table->string('declarant')->nullable()->after('address');
        });
    }

    public function down()
    {
        Schema::table('warehouses', function (Blueprint $table) {
            $table->dropColumn('declarant');
        });
    }
}

This migration adds a declarant column (string, nullable) to the warehouses table in each tenant's schema. This allows storing declarant information specific to each tenant's warehouses.

Filament Integration

Additionally, the update includes integrating Massive Upload relation managers and polling into ViewMassiveUpload. This enhances the user interface within Filament, enabling users to manage and monitor massive upload processes more efficiently.

Benefits

  • Improved data isolation and integrity within the multi-tenant architecture.
  • More efficient database queries by removing unnecessary scoping.
  • Enhanced user experience with Massive Upload management in Filament.

Conclusion

By correcting the database queries and updating the tenant schema, the platform achieves better multi-tenancy support and improves the user experience. This highlights the importance of continuous refinement in multi-tenant architectures to maintain data integrity and performance.

Enhancements to Tenant Warehouse Management in Platform
GERARDO RUIZ

GERARDO RUIZ

Author

Share: