Databases
TimescaleDB
Constraints

Constraints

TimescaleDB supports all PostgreSQL constraints.

Constraint TypeSchemaHero Version
PRIMARY KEYv0.1.0
FOREIGN KEYv0.2.0
UNIQUEv0.2.0
NOT NULLv0.1.0
CHECK
EXCLUSION

Hypertable Constraints

When using hypertables, there are some important considerations:

Primary Keys

Primary keys on hypertables must include the time column:

schema:
  timescaledb:
    primaryKey: [time, device_id]  # time column must be included

Unique Constraints

Unique constraints on hypertables must also include the time column:

indexes:
  - columns: [time, sensor_id]
    isUnique: true

Foreign Keys

Foreign keys referencing hypertables are supported but the referenced columns must include the partitioning column (time).

If there are any constraints missing, open an issue (opens in a new tab) to report it.