Official Engineering Deliverable • Section 24

FellaHost Company Limited

Commercial & Technical ICT Engineering Services • Enterprise Software Division

📍 P.O. Box 80079, Dar es Salaam, Tanzania 📞 0737 671 678 / +255 222 436 131 ✉️ [email protected] 🌐 www.fellahost.co.tz
TIN NO: 189-723-717
B.L.No: 20000105272
DOMAIN: logistics.domain.co.tz
DATE: September 2026
Deliverable ID: 02_Database_Migration_and_Seed_Scripts
Specification Section: 24. Deliverables for Software Development Team
Developers: FellaHost Company Limited
System Domain: logistics.domain.co.tz

FellaHost Company Limited

Project Developers & Software Engineering Specialists

Document Reference: Section 24 Deliverables for Software Development Team

System Designation: Integrated Clearing, Forwarding & Logistics System (ICFLS)

Corporate Entity: FellaHost Company Limited

Headquarters: P.O. Box 80079, Dar es Salaam, Tanzania


2. Database Migration and Seed Scripts Specification

Executive Overview

The ICFLS migration suite establishes a deterministic, reproducible, and verifiable MariaDB 10.11+ / MySQL 8.0 schema using Laravel Schema Builder. Foreign keys, indexed constraints, character encoding (utf8mb4_unicode_ci), and default baseline data seeds are strictly defined.


2.0 Fresh Server Installation, Composer Commands & Database Seeding Guide

2.0.1 Server Prerequisites Verification

Prior to deploying the ICFLS codebase, verify that the environment meets the enterprise runtime requirements:

# Verify PHP 8.2+ or 8.3 CLI with requisite extensions
php -v
php -m | grep -E '(pdo_mysql|mbstring|openssl|bcmath|curl|xml|zip|gd|intl)'

# Verify Composer 2.7+ availability
composer --version

# Verify MariaDB 10.11+ / MySQL 8.0 server engine
mariadb -V

2.0.2 Cloning & Composer Dependency Installation

Navigate to your web application root directory and execute composer in non-development mode:

# Navigate to deployment directory
cd /var/www/vhosts/fellahost.co.tz/icfls.fellahost.co.tz

# Install production dependencies with optimized classmap autoloader
composer install --no-dev --optimize-autoloader --no-interaction

2.0.3 Environment Configuration & Encryption Key Generation

# Copy baseline environment if .env is not present
cp -n .env.example .env

# Generate application cryptographic encryption key (AES-256-CBC)
php artisan key:generate --force

# Link public storage directory for media, documents and invoice PDFs
php artisan storage:link

2.0.4 Database Provisioning (MariaDB / MySQL)

# Connect to database daemon and create production database with utf8mb4 encoding
mariadb -u root -p << 'EOF'
CREATE DATABASE IF NOT EXISTS icfls_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'icfls_user'@'localhost' IDENTIFIED BY 'F6tvxfNIb6UECFMG9gYDCiM5';
GRANT ALL PRIVILEGES ON icfls_db.* TO 'icfls_user'@'localhost';
FLUSH PRIVILEGES;
EOF

Configure .env database parameters:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=icfls_db
DB_USERNAME=icfls_user
DB_PASSWORD="F6tvxfNIb6UECFMG9gYDCiM5"

2.0.5 Single-Command Automated Migration & Seeding Sequence

To initialize all relational tables and populate complete enterprise baseline data from a clean install:

# Execute fresh schema build and complete database seeding
php artisan migrate:fresh --seed --force

2.0.6 Granular Seeder Execution Commands

For targeted or staging environments where specific modules require isolated database seeding:

# 1. Regenerate Composer Classmap Autoloader
composer dump-autoload -o

# 2. Seed Security Roles & Permission Matrix (Admin, Customs, Fleet, Accounts)
php artisan db:seed --class=RolePermissionSeeder --force

# 3. Seed System Settings, Company Profile & FellaSMS Gateway Defaults
php artisan db:seed --class=SystemSettingSeeder --force

# 4. Seed User Accounts & Staff Operational Credentials
php artisan db:seed --class=UserSeeder --force

# 5. Seed Corporate Customers, Importers & Escrow Balances
php artisan db:seed --class=CustomerSeeder --force

# 6. Seed Consignment Jobs & Operational Checklists
php artisan db:seed --class=JobSeeder --force
php artisan db:seed --class=JobMilestoneSeeder --force

# 7. Seed TRA TANCIS Customs Declarations & HS Code Items
php artisan db:seed --class=DeclarationSeeder --force

# 8. Seed Shipping Containers, Demurrage Free-Days & Seals
php artisan db:seed --class=ContainerSeeder --force

# 9. Seed Compliance Verification Documents & File Attachments
php artisan db:seed --class=DocumentSeeder --force

# 10. Seed Transport Fleet, Haulage Vehicles & Registered Drivers
php artisan db:seed --class=VehicleSeeder --force
php artisan db:seed --class=DriverSeeder --force

# 11. Seed Active Logistics Trips, Fuel Vouchers & Tracking Logs
php artisan db:seed --class=TripSeeder --force

# 12. Seed Commercial Invoices, Receipts & Ledger Accounts
php artisan db:seed --class=InvoiceSeeder --force

# 13. Master Aggregator Seeder Execution
php artisan db:seed --class=DatabaseSeeder --force

2.0.7 Post-Installation Performance Optimization & Cache Warming

# Compile and cache framework artifacts for low-latency HTTP dispatch
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache

# Set secure Linux file ownership and permissions
chown -R fellahost:psacln /var/www/vhosts/fellahost.co.tz/icfls.fellahost.co.tz
chmod -R 775 storage bootstrap/cache

2.1 Core Relational Schema Migrations


<?php

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

return new class extends Migration
{
    public function up(): void
    {
        // 1. Customers Table
        Schema::create('customers', function (Blueprint $table) {
            $table->id();
            $table->string('customer_code', 32)->unique();
            $table->string('company_name', 191);
            $table->string('tin_number', 32)->index();
            $table->string('vrn_number', 32)->nullable();
            $table->string('email', 120)->index();
            $table->string('phone', 32);
            $table->decimal('credit_limit_tzs', 14, 2)->default(0.00);
            $table->decimal('escrow_balance_tzs', 14, 2)->default(0.00);
            $table->enum('status', ['Active', 'Suspended', 'Archived'])->default('Active');
            $table->timestamps();
        });

        // 2. Consignment Jobs Table
        Schema::create('jobs', function (Blueprint $table) {
            $table->id();
            $table->string('job_number', 40)->unique();
            $table->foreignId('customer_id')->constrained('customers')->onDelete('restrict');
            $table->string('bl_number', 64)->index();
            $table->string('vessel_name', 120)->nullable();
            $table->text('cargo_description');
            $table->string('port_of_entry', 64)->default('Dar es Salaam Port');
            $table->string('destination_city', 64);
            $table->enum('status', [
                'Draft', 'Docs_Pending', 'Customs_Processing',
                'Cleared', 'Dispatched', 'In_Transit',
                'Delivered', 'Invoiced', 'Closed'
            ])->default('Draft')->index();
            $table->timestamps();
        });

        // 3. Customs Declarations Table
        Schema::create('declarations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('job_id')->constrained('jobs')->onDelete('cascade');
            $table->string('tancis_reference', 64)->unique();
            $table->string('customs_office_code', 16)->default('TZDAR');
            $table->decimal('total_cif_tzs', 16, 2)->default(0.00);
            $table->decimal('total_duties_tzs', 16, 2)->default(0.00);
            $table->enum('assessment_status', [
                'Pending_Lodgement', 'Lodged', 'Assessed',
                'Duty_Paid', 'Release_Order_Issued'
            ])->default('Pending_Lodgement')->index();
            $table->timestamp('assessed_at')->nullable();
            $table->timestamp('released_at')->nullable();
            $table->timestamps();
        });

        // 4. Containers Table
        Schema::create('containers', function (Blueprint $table) {
            $table->id();
            $table->foreignId('job_id')->constrained('jobs')->onDelete('cascade');
            $table->string('container_number', 32)->unique();
            $table->string('size_type', 16)->default('40FT_HC');
            $table->string('shipping_line', 64);
            $table->date('discharge_date');
            $table->integer('free_days_allowed')->default(14);
            $table->date('demurrage_commences_at');
            $table->enum('status', ['At_Port', 'In_Transit', 'Delivered', 'Returned_Empty'])->default('At_Port');
            $table->timestamps();
        });

        // 5. Commercial Invoices Table
        Schema::create('invoices', function (Blueprint $table) {
            $table->id();
            $table->string('invoice_number', 40)->unique();
            $table->foreignId('customer_id')->constrained('customers')->onDelete('restrict');
            $table->foreignId('job_id')->constrained('jobs')->onDelete('restrict');
            $table->string('currency', 8)->default('TZS');
            $table->decimal('subtotal', 16, 2)->default(0.00);
            $table->decimal('vat_amount', 16, 2)->default(0.00);
            $table->decimal('total_amount', 16, 2)->default(0.00);
            $table->enum('payment_status', ['Unpaid', 'Partially_Paid', 'Paid', 'Cancelled'])->default('Unpaid');
            $table->date('due_date');
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('invoices');
        Schema::dropIfExists('containers');
        Schema::dropIfExists('declarations');
        Schema::dropIfExists('jobs');
        Schema::dropIfExists('customers');
    }
};

2.2 Baseline System Seeders


<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;

class SystemMasterSeeder extends Seeder
{
    public function run(): void
    {
        // Default Super Administrator
        DB::table('users')->updateOrInsert(
            ['email' => '[email protected]'],
            [
                'name' => 'System Administrator',
                'password_hash' => Hash::make('AdminSecure2026!'),
                'role' => 'admin',
                'status' => 'Active',
                'is_active' => 1,
                'two_factor_enabled' => 1,
                'two_factor_channel' => 'email',
                'created_at' => now(),
            ]
        );

        // Core System Settings
        $settings = [
            ['key' => 'company_name', 'value' => 'Integrated CF Logistics System'],
            ['key' => 'company_short_name', 'value' => 'ICFLS'],
            ['key' => 'company_domain', 'value' => 'domain.co.tz'],
            ['key' => 'two_factor_master_enabled', 'value' => '1'],
            ['key' => 'demurrage_alert_threshold_days', 'value' => '3'],
            ['key' => 'default_currency', 'value' => 'TZS'],
            ['key' => 'vat_rate_percentage', 'value' => '18.00'],
        ];

        foreach ($settings as $s) {
            DB::table('system_settings')->updateOrInsert(['key' => $s['key']], $s);
        }

        // East African Border Ports
        $ports = [
            ['iso_code' => 'TZA', 'port_name' => 'Dar es Salaam Maritime Port'],
            ['iso_code' => 'TZA', 'port_name' => 'Tunduma Border (Zambia Corridor)'],
            ['iso_code' => 'TZA', 'port_name' => 'Kasumulu Border (Malawi Corridor)'],
            ['iso_code' => 'TZA', 'port_name' => 'Rusumo Border (Rwanda Corridor)'],
            ['iso_code' => 'TZA', 'port_name' => 'Mutukula Border (Uganda Corridor)'],
            ['iso_code' => 'TZA', 'port_name' => 'Namanga Border (Kenya Corridor)'],
        ];

        foreach ($ports as $p) {
            DB::table('system_ports')->updateOrInsert(['port_name' => $p['port_name']], $p);
        }
    }
}

Regulatory Notice

We're Top leading Company Registering under Commercial & Technical ICT Services TIN NO: 189-723-717
FellaHost Company Limited — Project Developers & Engineering Specialists.
Confidential & Proprietary Enterprise Asset — All Rights Reserved.