Skip to content

[BE-38] Multi-location support: backend data model #1223

Description

@yusuftomilola

Overview

ManageHub supports only a single physical location. Hub operators running multiple sites (e.g. two Lagos branches, one Abuja branch) cannot manage all locations under one account. Multi-location support is a critical feature for growing hub operators.

Context

  • Workspace entity: backend/src/workspaces/entities/workspace.entity.ts
  • WorkspaceLog entity: backend/src/workspace-tracking/entities/workspace-log.entity.ts
  • Booking entity: backend/src/bookings/entities/booking.entity.ts
  • This is a schema-level change — requires a TypeORM migration, not just synchronize: true

Tasks

  • Create Location entity: id, name, address, city, country (default "Nigeria"), timezone (IANA timezone string, e.g. "Africa/Lagos"), isActive (bool), createdAt, updatedAt
  • Add nullable locationId FK to Workspace entity; existing workspaces get a default location seeded in migration
  • POST /locations — create location (super_admin only)
  • GET /locations — list all active locations (all authenticated users)
  • PATCH /locations/:id — update location details (super_admin only)
  • GET /workspaces — support ?locationId= filter to scope results to a location
  • Admin analytics endpoints support ?locationId= filter for cross-location reporting
  • Generate TypeORM migration: npm run migration:generate -- src/migrations/AddLocationEntity

Files to Modify / Create

  • New: backend/src/locations/ (module, entity, controller, service)
  • backend/src/workspaces/entities/workspace.entity.ts
  • backend/src/workspaces/workspaces.controller.ts
  • New: backend/src/migrations/AddLocationEntity.ts
  • backend/src/app.module.ts

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions