Store Console

Historical Data on MongoDB

Historical Data on MongoDB

By default every table lives on your app's main connection (PostgreSQL or MySQL) — nothing about this feature changes that unless you opt in. Self-hosted stores with a lot of append-only history (activity log entries, chat transcripts, CRM email history) can move just those tables onto a separate connection, including MongoDB, without touching anything else.

What Moves

  • Activity log — the activity_log table (every create/update/delete/login audit entry)
  • Chat messages — the Messaging module's msg_messages table
  • CRM email history — the crm_email_messages and crm_email_events tables

Everything else — orders, products, customers, accounting — always stays on your primary connection. This is a targeted move for high-volume, rarely-joined history tables only.

Option A: Another SQL Connection

Point history at any connection already defined in config/database.php (for example a second Postgres database dedicated to logs):

HISTORICAL_DB_CONNECTION=pgsql_history

This works immediately with no extra packages — it is plain Eloquent on a plain SQL connection.

Option B: MongoDB

A mongodb connection template ships in config/database.php already, but it is inert until you opt in:

HISTORICAL_DB_CONNECTION=mongodb
MONGODB_URI=mongodb://user:password@host:27017
MONGODB_DATABASE=storeconsole_history

MongoDB support requires two things this platform does not install by default:

  • The mongodb PHP extension on your server
  • composer require mongodb/laravel-mongodb (listed under suggest in the root composer.json)

Without the extension and package installed, setting HISTORICAL_DB_CONNECTION=mongodb is safely ignored — every model falls back to the default connection and the app boots and runs exactly as before.

Full MongoDB Model Support

Once mongodb/laravel-mongodb is installed, connection switching alone gives you query-builder-level access to the Mongo collection. For full Eloquent support (BSON casts, ObjectId primary keys, embedded documents) also add the package's MongoDB\Laravel\Eloquent\DocumentModel trait to the model, alongside the connection-switching trait this platform already ships on the history models:

use AnisAronno\PlatformKit\Traits\UsesHistoricalConnection;
use MongoDB\Laravel\Eloquent\DocumentModel;

class Activity extends SpatieActivity
{
    use UsesHistoricalConnection;
    use DocumentModel;
}

Because Store Console ships as full source per license, this one-line addition is a normal customization to your own copy — not a vendor patch.

How to Revert

Unset HISTORICAL_DB_CONNECTION (or set it back to empty) and every model returns to the default connection on the next request — no migration required to turn the feature off.

Last updated: 7/13/2026

About Us

We are committed to providing the best products and services to our customers.

Our Location

House 32, Road 29, Mirpur 12, Dhaka, Bangladesh

Menu items will appear here once configured.

© 2026 Store Console. All rights reserved.