I installed timescaleDb using Docker following this tutorial for the setup: https://docs.timescale.com/self-hosted/latest/install/installation-docker/ . I used this image : timescale/timescaledb-ha:pg14-latest
Then I connected to the instance with pgAdmin and followed this official tutorial: https://docs.timescale.com/getting-started/latest/tables-hypertables/.
CREATE DATABASE "test-timescale";
CREATE TABLE IF NOT EXISTS "Measurements" (
"Id" SERIAL PRIMARY KEY,
"DeviceId" VARCHAR(255) NOT NULL,
"SensorId" VARCHAR(255) NOT NULL,
"Timestamp" TIMESTAMPTZ NOT NULL,
"Temperature" DECIMAL(10, 2)
);
However when I try to run the command for creating hypertables I get an error that the by_range function does not exist
SELECT create_hypertable('Measurements', by_range('Timestamp'));
The error:
LINE 1: SELECT create_hypertable('Measurements', by_range('Timestamp...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
I checked that I have the timescaleDb extension installed and created. Also tried changing the quotes to doubles, but without success.
What am I missing here?
You're probably trying to use TimescaleDB 2.13+ syntax (the
by_range()thing) on an earlier version. You can revert to the old one. Note the case-sensitivity. Demo at db<>fiddle:When running this,
"Id"can't be a primary key, because it would mean it's unique on its own; Timescale requires that if there's a unique constraint, the partition key needs to be a part of it: