How should I configure TimescaleDB ( Postgres ) in laravel homestead

1.5k views Asked by At

I'm trying to use homestead from laravel ecosystem.

I can make it work with a postgreSQL DB, but I have no TimescaleDB capabilities.

I installed postgres 12 with those lines in homestead.yaml

services:
    - enabled:
        - "postgresql@12-main"

I tried to install it manually with as mentionned in timescaleDB docs, but I think it installed a different versions:

postgres  9188  0.0  1.3 353756 28068 ?        S    08:11   0:00 /usr/lib/postgresql/11/bin/postgres -D /var/lib/postgresql/11/main -c config_file=/etc/postgresql/11/main/postgresql.conf
postgres  9191  0.0  2.3 757760 48108 ?        Ss   08:11   0:00 /usr/lib/postgresql/12/bin/postgres -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf
postgres  9193  0.0  1.3 353396 27716 ?        S    08:11   0:00 /usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf
postgres  9196  0.0  0.3 353884  6916 ?        Ss   08:11   0:00 postgres: 11/main: checkpointer   
postgres  9197  0.0  0.2 353756  4172 ?        Ss   08:11   0:00 postgres: 11/main: background writer   
postgres  9198  0.0  0.4 353756  9056 ?        Ss   08:11   0:00 postgres: 11/main: walwriter   
postgres  9199  0.0  0.3 354160  6696 ?        Ss   08:11   0:00 postgres: 11/main: autovacuum launcher   
postgres  9200  0.0  0.1 208672  3560 ?        Ss   08:11   0:00 postgres: 11/main: stats collector   
postgres  9201  0.0  0.2 354160  4996 ?        Ss   08:11   0:00 postgres: 11/main: logical replication launcher   
postgres  9203  0.0  0.3 353508  7092 ?        Ss   08:11   0:00 postgres: 10/main: checkpointer process   
postgres  9204  0.0  0.2 353396  4216 ?        Ss   08:11   0:00 postgres: 10/main: writer process   
postgres  9205  0.0  0.4 353396  9232 ?        Ss   08:11   0:00 postgres: 10/main: wal writer process   
postgres  9206  0.0  0.3 353804  6940 ?        Ss   08:11   0:00 postgres: 10/main: autovacuum launcher process   
postgres  9207  0.0  0.1 208452  3660 ?        Ss   08:11   0:00 postgres: 10/main: stats collector process   
postgres  9208  0.0  0.2 353680  5044 ?        Ss   08:11   0:00 postgres: 10/main: bgworker: logical replication launcher   
postgres  9209  0.0  0.5 757864 10380 ?        Ss   08:11   0:00 postgres: 12/main: checkpointer   
postgres  9210  0.0  0.3 757760  6672 ?        Ss   08:11   0:00 postgres: 12/main: background writer   
postgres  9211  0.0  1.0 757760 21068 ?        Ss   08:11   0:00 postgres: 12/main: walwriter   
postgres  9212  0.0  0.3 758436  7128 ?        Ss   08:11   0:00 postgres: 12/main: autovacuum launcher   
postgres  9213  0.0  0.2 211220  5108 ?        Ss   08:11   0:00 postgres: 12/main: stats collector   
postgres  9214  0.0  0.3 758320  7588 ?        Ss   08:11   0:00 postgres: 12/main: TimescaleDB Background Worker Launcher   
postgres  9215  0.0  0.3 758308  7072 ?        Ss   08:11   0:00 postgres: 12/main: logical replication launcher   
postgres  9223  0.6  1.9 781872 39828 ?        Ss   08:11   0:02 postgres: 12/main: homestead mydb 10.0.2.2(41896) idle
postgres  9228  0.0  1.2 315744 26120 ?        S    08:11   0:00 /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf
postgres  9230  0.0  0.2 315744  4268 ?        Ss   08:11   0:00 postgres: 9.6/main: checkpointer process   
postgres  9231  0.0  0.2 315744  4268 ?        Ss   08:11   0:00 postgres: 9.6/main: writer process   
postgres  9232  0.0  0.2 315744  4268 ?        Ss   08:11   0:00 postgres: 9.6/main: wal writer process   
postgres  9233  0.0  0.3 316156  6844 ?        Ss   08:11   0:00 postgres: 9.6/main: autovacuum launcher process   
postgres  9234  0.0  0.1 170744  3356 ?        Ss   08:11   0:00 postgres: 9.6/main: stats collector process   
postgres  9408  0.0  0.8 759028 17224 ?        Ss   08:13   0:00 postgres: 12/main: homestead mydb 10.0.2.2(42982) idle
postgres  9450  0.0  1.0 759640 21604 ?        Ss   08:14   0:00 postgres: 12/main: homestead mydb 10.0.2.2(43680) idle
postgres  9485  0.0  0.8 759028 17220 ?        Ss   08:15   0:00 postgres: 12/main: homestead mydb 10.0.2.2(44028) idle
postgres  9486  0.0  1.9 778188 39540 ?        Ss   08:15   0:00 postgres: 12/main: homestead postgres 10.0.2.2(44052) idle
postgres  9490  0.0  0.8 759028 17228 ?        Ss   08:15   0:00 postgres: 12/main: homestead mydb 10.0.2.2(44150) idle
postgres  9523  0.1  1.4 769688 30464 ?        Ss   08:16   0:00 postgres: 12/main: homestead homestead 10.0.2.2(44612) idle

In PGAdmin, in local, I can see several schema prefixed with timescaledb:

_timescaledb_cache
_timescaledb_catalog
_timescaledb_config
_timescaledb_internal

But I can't see it in homestead.

Besides, when I try to create a hypertable with:

SELECT create_hypertable('measures', 'time');

I get:

ERROR:  function create_hypertable(unknown, unknown) does not exist
LINE 1: SELECT create_hypertable('measures', 'time');
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 8

I can see there is a feature called timescaledb in git repo, but there is no docs on how should I call it.

Is there a way to have built-in support for timescale or how should I do ???

EDIT: I could install timescaledb using homestead features:

features:
    - mariadb: false
    - mysql: false
    - timescaledb: true

but it still gives me the same error...

1

There are 1 answers

1
Juliatzin On

The solution is in the docs:

Once you have installed timescale, you must install extension:

CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

Warning: In homestead, this is the TimescaleDB OSS version. There is a lot of missing feature you will find in communit version which also free

Feature not supported: 7 ERROR: function "time_bucket_gapfill" is not supported under the current license "ApacheOnly"

HINT: Upgrade to a Timescale-licensed binary to access this free community feature

So, for me, I had to uninstall Homestead version, and reinstall community version. Not sure why Homestead is using OSS Version.