Appearance
Entity: gaugeFormulaMember
Entity Type: Database table
Description: One term of a gaugeFormula version: which gauge (channel) enters the formula and with which sign. The formula editor shows the sign as + / −; the stored coefficient is the signed weight of the term (+1 / −1 from the form, any non-zero number through the API for weighted formulas). Members belong to a version — a new version carries its own member rows, so the members of a past version stay as they were.
Source of the current shape: EM3 apps/backend/migrations/202609011000-gauge-formula.sql (gauge_formula_member), member rules in apps/backend/src/core/assets/domain/rules/formula-member.rules.ts.
Data Attributes Table
| Attribute Name | Description | Data Type | Default Value | Required (= Nullable) | Unique | Format | Validations | Index | Example |
|---|---|---|---|---|---|---|---|---|---|
| id | Primary key of the member row. | UUID | Generated in code (app layer) | Yes | Yes | UUID v7 | - | Primary Key | 01960000-0000-7000-8000-000000000411 |
| tenantId | Tenant that owns this record. Denormalised from gaugeFormula; row-level security policy tenant_isolation. | UUID | - | Yes | No | UUID v7 | Foreign Key → tenant; must equal gaugeFormula.tenantId. | name: idx_gaugeFormulaMember_tenantId, type: btree | 01960000-0000-7000-8000-000000000099 |
| formulaId | The formula version this term belongs to. | UUID | - | Yes | No | UUID v7 | Foreign Key → gaugeFormula. | name: idx_gaugeFormulaMember_formulaId, type: btree | 01960000-0000-7000-8000-000000000401 |
| memberGaugeId | The gauge whose effective consumption enters the formula. | UUID | - | Yes | No | UUID v7 | Foreign Key → gauge. Not the owner itself; not archived at the time of saving; not a buildingTotal; unique within the version. A computed virtual gauge is allowed when it does not lead back to the owner. Same medium as the owner for buildingTotal; for computed the form offers the owner's medium only (open whether the API keeps allowing other media). | name: idx_gaugeFormulaMember_memberGaugeId, type: btree | 01960000-0000-7000-8000-000000000003 |
| coefficient | Signed weight of the term. The form writes 1 for + and −1 for −. | Decimal | 1 | Yes | No | Decimal(18,6) | Not zero (CHECK (coefficient <> 0)). | - | -1.000000 |
| sortOrder | Position of the term in the editor, so the formula reads back in the order the user wrote it. | Integer | 0 | Yes | No | - | Zero or greater; unique within the version. | - | 1 |
| createdAt | Timestamp of entity creation. Immutable. | Timestamp with time zone | Set in code | Yes | No | ISO 8601 | - | - | 2026-09-24T09:00:00Z |
| updatedAt | Timestamp of last entity update. Set on insert equal to createdAt. | Timestamp with time zone | Set in code | Yes | No | ISO 8601 | - | - | 2026-09-24T09:00:00Z |
| deletedAt | Timestamp of soft delete. Versions are voided, not deleted; kept for the uniform lifecycle. Once set, immutable. | Timestamp with time zone | null | No | No | ISO 8601 | - | - | null |
| createdBy | Identifier of the actor who created this record. | String | - | Yes | No | type:actor | - | - | user:01960000-0000-7000-8000-000000000099 |
| updatedBy | Identifier of the actor who last updated this record. | String | - | Yes | No | type:actor | - | - | user:01960000-0000-7000-8000-000000000099 |
Audited fields
Recorded on created (in full), updated (changed only) and deleted (in full): formulaId, memberGaugeId, coefficient, sortOrder.
Excluded: none — a member is the formula.
Not registered for entityName resolution — join row; identified by its formulaId/memberGaugeId scope.
Row-level security
Enabled and forced, with the tenant-isolation policy every tenant-schema table carries (tenant_isolation on app.tenant_id).
Notes
- Uniqueness of (
formulaId,memberGaugeId) is enforced in the database; the rules layer reports a duplicate as a descriptive validation error before the insert. - Archiving a member gauge does not delete the row — it sets
needsReviewon the formula so the user decides.