Skip to content

Commit

Permalink
Added timescaledb plugin/extension (#488)
Browse files Browse the repository at this point in the history
* Added `timescaledb` plugin/extension

* updated postgresql image sum
  • Loading branch information
TakoB222 authored May 29, 2024
1 parent 582b3b9 commit ed4620a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ options:
default: false
type: boolean
description: Enable pgvector extension
plugin_timescaledb_enable:
default: false
type: boolean
description: Enable timescaledb extension
profile:
description: |
Profile representing the scope of deployment, and used to tune resource allocation.
Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resources:
postgresql-image:
type: oci-image
description: OCI image for PostgreSQL
upstream-source: ghcr.io/canonical/charmed-postgresql@sha256:31cf150b4523481202c1ff9b7b5d7f0b36729edad89d61242d8f1eb56b2912c0
upstream-source: ghcr.io/canonical/charmed-postgresql@sha256:76ef26c7d11a524bcac206d5cb042ebc3c8c8ead73fa0cd69d21921552db03b6

peers:
database-peers:
Expand Down
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CharmConfig(BaseConfigModel):
plugin_postgis_topology_enable: bool
plugin_postgis_raster_enable: bool
plugin_vector_enable: bool
plugin_timescaledb_enable: bool
request_date_style: Optional[str]
request_standard_conforming_strings: Optional[bool]
request_time_zone: Optional[str]
Expand Down
1 change: 1 addition & 0 deletions templates/patroni.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bootstrap:
log_truncate_on_rotation: 'on'
logging_collector: 'on'
wal_level: logical
shared_preload_libraries: 'timescaledb'
{%- if pg_parameters %}
{%- for key, value in pg_parameters.items() %}
{{key}}: {{value}}
Expand Down
12 changes: 8 additions & 4 deletions tests/integration/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@
ADDRESS_STANDARDIZER_EXTENSION_STATEMENT = "SELECT num, street, city, zip, zipplus FROM parse_address('1 Devonshire Place, Boston, MA 02109-1234');"
ADDRESS_STANDARDIZER_DATA_US_EXTENSION_STATEMENT = "SELECT house_num, name, suftype, city, country, state, unit FROM standardize_address('us_lex', 'us_gaz', 'us_rules', 'One Devonshire Place, PH 301, Boston, MA 02109');"
POSTGIS_TIGER_GEOCODER_EXTENSION_STATEMENT = "SELECT * FROM standardize_address('tiger.pagc_lex', 'tiger.pagc_gaz', 'tiger.pagc_rules', 'One Devonshire Place, PH 301, Boston, MA 02109-1234');"
POSTGIS_TOPOLOGY_STATEMENT = "SELECT topology.CreateTopology('nyc_topo', 26918, 0.5);"
POSTGIS_RASTER_STATEMENT = "CREATE TABLE test_postgis_raster (name varchar, rast raster);"
POSTGIS_TOPOLOGY_EXTENSION_STATEMENT = "SELECT topology.CreateTopology('nyc_topo', 26918, 0.5);"
POSTGIS_RASTER_EXTENSION_STATEMENT = (
"CREATE TABLE test_postgis_raster (name varchar, rast raster);"
)
VECTOR_EXTENSION_STATEMENT = (
"CREATE TABLE vector_test (id bigserial PRIMARY KEY, embedding vector(3));"
)
TIMESCALEDB_EXTENSION_STATEMENT = "CREATE TABLE test_timescaledb (time TIMESTAMPTZ NOT NULL); SELECT create_hypertable('test_timescaledb', 'time');"


@pytest.mark.group(1)
Expand Down Expand Up @@ -146,9 +149,10 @@ async def test_plugins(ops_test: OpsTest) -> None:
"plugin_address_standardizer_enable": ADDRESS_STANDARDIZER_EXTENSION_STATEMENT,
"plugin_address_standardizer_data_us_enable": ADDRESS_STANDARDIZER_DATA_US_EXTENSION_STATEMENT,
"plugin_postgis_tiger_geocoder_enable": POSTGIS_TIGER_GEOCODER_EXTENSION_STATEMENT,
"plugin_postgis_raster_enable": POSTGIS_RASTER_STATEMENT,
"plugin_postgis_topology_enable": POSTGIS_TOPOLOGY_STATEMENT,
"plugin_postgis_raster_enable": POSTGIS_RASTER_EXTENSION_STATEMENT,
"plugin_postgis_topology_enable": POSTGIS_TOPOLOGY_EXTENSION_STATEMENT,
"plugin_vector_enable": VECTOR_EXTENSION_STATEMENT,
"plugin_timescaledb_enable": TIMESCALEDB_EXTENSION_STATEMENT,
}

def enable_disable_config(enabled: False):
Expand Down

0 comments on commit ed4620a

Please sign in to comment.