Feature: Dynamic SQLite Database Routing #2

Closed
opened 2026-06-25 19:30:21 +00:00 by psycodepath · 0 comments
Owner

Motivation

Each tenant's data must be fully isolated to ensure security and privacy. Running separate SQLite databases per tenant is the cleanest way to achieve this.

Description

Refactor the Dependency Injection configuration for PDO to dynamically resolve the database path based on the current TenantContext.

User Story

As a tenant, I want my data stored in a completely separate database file from other tenants so that there is zero risk of data leakage.

Gherkin Feature

Feature: Dynamic SQLite Database Routing
  As the application
  I want to resolve the SQLite database path based on the active tenant
  So that data isolation is guaranteed

  Scenario: Tenant database connection
    Given the active tenant is "family1"
    When a database query is executed
    Then the query should run against "var/tenant_family1.sqlite"

Acceptance Criteria

  • Refactor PDO factory in AppBootstrap.php to fetch TenantContext.
  • Dynamic database file path resolved to var/tenant_<tenant_id>.sqlite.
  • Database file automatically initialized if it does not exist.
### Motivation Each tenant's data must be fully isolated to ensure security and privacy. Running separate SQLite databases per tenant is the cleanest way to achieve this. ### Description Refactor the Dependency Injection configuration for `PDO` to dynamically resolve the database path based on the current `TenantContext`. ### User Story As a tenant, I want my data stored in a completely separate database file from other tenants so that there is zero risk of data leakage. ### Gherkin Feature ```gherkin Feature: Dynamic SQLite Database Routing As the application I want to resolve the SQLite database path based on the active tenant So that data isolation is guaranteed Scenario: Tenant database connection Given the active tenant is "family1" When a database query is executed Then the query should run against "var/tenant_family1.sqlite" ``` ### Acceptance Criteria - [ ] Refactor `PDO` factory in `AppBootstrap.php` to fetch `TenantContext`. - [ ] Dynamic database file path resolved to `var/tenant_<tenant_id>.sqlite`. - [ ] Database file automatically initialized if it does not exist.
psycodepath added reference issue/2-database-routing 2026-07-04 21:36:07 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
psycodepath/hrp#2
No description provided.