Skip to content

Commit

Permalink
Fix h2 schema and syntax for migrations 17 and 18
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Dec 2, 2019
1 parent 3783445 commit d36beec
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/server/src/main/resources/db/h2/V17_0_0__multi_instance.sql
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
-- H2-compatible version of multi-instance reaper Postgres DDL
-- CHANGES:
-- "node" TEXT --> "node" VARCHAR(255) because H2 doesn't support index on TEXT
-- node VARCHAR --> node VARCHAR(255) because H2 doesn't support index on VARCHAR

CREATE TABLE IF NOT EXISTS leader (
leader_id BIGINT PRIMARY KEY,
reaper_instance_id BIGINT,
reaper_instance_host TEXT,
reaper_instance_host VARCHAR,
last_heartbeat TIMESTAMP WITH TIME ZONE
);

CREATE TABLE IF NOT EXISTS running_reapers (
reaper_instance_id BIGINT PRIMARY KEY,
reaper_instance_host TEXT,
reaper_instance_host VARCHAR,
last_heartbeat TIMESTAMP WITH TIME ZONE
);

CREATE TABLE IF NOT EXISTS node_metrics_v1 (
time_partition BIGINT,
run_id BIGINT,
node VARCHAR(255),
cluster TEXT,
datacenter TEXT,
ts TIMESTAMP WITH TIME ZONE,
node VARCHAR,
cluster VARCHAR,
datacenter VARCHAR,
requested BOOLEAN,
pending_compactions INT,
has_repair_running BOOLEAN,
active_anticompactions INT,
PRIMARY KEY(run_id, time_partition, node)
PRIMARY KEY (run_id, ts, node)
);
34 changes: 34 additions & 0 deletions src/server/src/main/resources/db/h2/V18_0_0__sidecar_mode.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CREATE TABLE IF NOT EXISTS node_metrics_v2_source_nodes (
source_node_id SERIAL UNIQUE,
cluster VARCHAR,
host VARCHAR,
last_updated TIMESTAMP WITH TIME ZONE,
PRIMARY KEY (cluster, host)
);

CREATE TABLE IF NOT EXISTS node_metrics_v2_metric_types (
metric_type_id SERIAL UNIQUE,
metric_domain VARCHAR,
metric_type VARCHAR,
metric_scope VARCHAR,
metric_name VARCHAR,
metric_attribute VARCHAR,
PRIMARY KEY (metric_domain, metric_type, metric_scope, metric_name, metric_attribute)
);

CREATE TABLE IF NOT EXISTS node_metrics_v2 (
metric_type_id INT,
source_node_id INT,
ts TIMESTAMP WITH TIME ZONE,
value DOUBLE PRECISION,
PRIMARY KEY (metric_type_id, source_node_id, ts)
);

CREATE TABLE IF NOT EXISTS node_operations (
cluster VARCHAR,
type VARCHAR,
host VARCHAR,
ts TIMESTAMP WITH TIME ZONE,
data VARCHAR,
PRIMARY KEY (cluster, type, host, ts)
);

0 comments on commit d36beec

Please sign in to comment.