Skip to content

Commit

Permalink
Add the database scheme in Flyway
Browse files Browse the repository at this point in the history
  • Loading branch information
thijslemmens committed Dec 7, 2022
1 parent fab0919 commit 55f704b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dependencies {
implementation 'org.springframework.integration:spring-integration-mqtt'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.integration:spring-integration-jdbc'
implementation 'org.flywaydb:flyway-core'

annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

runtimeOnly group: 'org.postgresql', name: 'postgresql', version: '42.5.1'
Expand Down
2 changes: 0 additions & 2 deletions src/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ services:
image: docker.io/timescale/timescaledb:latest-pg14
ports:
- 5555:5432
volumes:
- ./postgres/schema.sql:/docker-entrypoint-initdb.d/schema.sql
environment:
- TIMESCALEDB_TELEMETRY=off
- POSTGRES_USER=mqtt_to_pg
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ spring:
mqtt-to-pg:
mqtt-client-id: mqtt-to-pg
mqtt-topic: tele/p1monitor/RESULT
mqtt-url: tcp://192.168.0.23:1883
mqtt-url: tcp://192.168.0.22:32433
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE EXTENSION IF NOT EXISTS hstore;

CREATE TABLE metrics (
time TIMESTAMPTZ NOT NULL,
name TEXT NOT NULL,
value DOUBLE PRECISION NOT NULL,
labels hstore NULL,
unit text NULL,
UNIQUE (time, name, labels)
time TIMESTAMPTZ NOT NULL,
name TEXT NOT NULL,
value DOUBLE PRECISION NOT NULL,
labels hstore NULL,
unit text NULL,
UNIQUE (time, name, labels)
);

create index metrics_name on metrics using btree (name);
Expand All @@ -31,7 +31,7 @@ WHERE
name = 'electricity.meter'
GROUP BY
time_1min
WITH NO DATA;
WITH NO DATA;

SELECT add_continuous_aggregate_policy('electricity_1min',
start_offset => INTERVAL '10 minutes',
Expand All @@ -51,7 +51,7 @@ WHERE
name = 'gas.meter'
GROUP BY
time_5min
WITH NO DATA;
WITH NO DATA;

SELECT add_continuous_aggregate_policy('gas_5min',
start_offset => INTERVAL '1 hour',
Expand Down

0 comments on commit 55f704b

Please sign in to comment.