From 3ad1221e551a0dde76746d7d500feea8ddba4267 Mon Sep 17 00:00:00 2001 From: Vlad Lazar Date: Fri, 26 Jul 2024 16:49:51 +0100 Subject: [PATCH] storcon/diesel: add leader table --- .../2024-07-26-140924_create_leader/down.sql | 1 + .../migrations/2024-07-26-140924_create_leader/up.sql | 6 ++++++ storage_controller/src/schema.rs | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 storage_controller/migrations/2024-07-26-140924_create_leader/down.sql create mode 100644 storage_controller/migrations/2024-07-26-140924_create_leader/up.sql diff --git a/storage_controller/migrations/2024-07-26-140924_create_leader/down.sql b/storage_controller/migrations/2024-07-26-140924_create_leader/down.sql new file mode 100644 index 0000000000..89d9aecd9b --- /dev/null +++ b/storage_controller/migrations/2024-07-26-140924_create_leader/down.sql @@ -0,0 +1 @@ +DROP TABLE leader; diff --git a/storage_controller/migrations/2024-07-26-140924_create_leader/up.sql b/storage_controller/migrations/2024-07-26-140924_create_leader/up.sql new file mode 100644 index 0000000000..dd1fc628c7 --- /dev/null +++ b/storage_controller/migrations/2024-07-26-140924_create_leader/up.sql @@ -0,0 +1,6 @@ +CREATE TABLE leader ( + hostname VARCHAR NOT NULL, + port INTEGER NOT NULL, + started_at TIMESTAMPTZ NOT NULL, + PRIMARY KEY(hostname, port, started_at) +); diff --git a/storage_controller/src/schema.rs b/storage_controller/src/schema.rs index cb5ba3f38b..1b58b8b1ce 100644 --- a/storage_controller/src/schema.rs +++ b/storage_controller/src/schema.rs @@ -1,5 +1,13 @@ // @generated automatically by Diesel CLI. +diesel::table! { + leader (hostname, port, started_at) { + hostname -> Varchar, + port -> Int4, + started_at -> Timestamptz, + } +} + diesel::table! { metadata_health (tenant_id, shard_number, shard_count) { tenant_id -> Varchar, @@ -36,4 +44,4 @@ diesel::table! { } } -diesel::allow_tables_to_appear_in_same_query!(metadata_health, nodes, tenant_shards,); +diesel::allow_tables_to_appear_in_same_query!(leader, metadata_health, nodes, tenant_shards,);