From 4d403632f5d8f56b62247eb8f82174789bcdeb08 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 4 Dec 2024 11:58:07 -0800 Subject: [PATCH] add migration for hmac keys database --- .../down.sql | 1 + .../2024-12-04-194513_hmac-keys-records-table/up.sql | 11 +++++++++++ xmtp_mls/src/storage/encrypted_store/schema.rs | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100644 xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/down.sql create mode 100644 xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/up.sql diff --git a/xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/down.sql b/xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/down.sql new file mode 100644 index 000000000..992e800e0 --- /dev/null +++ b/xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS "hmac_key_records"; diff --git a/xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/up.sql b/xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/up.sql new file mode 100644 index 000000000..b4a679a4d --- /dev/null +++ b/xmtp_mls/migrations/2024-12-04-194513_hmac-keys-records-table/up.sql @@ -0,0 +1,11 @@ +CREATE TABLE "hmac_key_records"( + -- Group ID that the Hmac keys are associated with + "group_id" BLOB NOT NULL, + -- Dm ID that the Hmac keys are associated with + "dm_id" TEXT, + -- The hmac key + "hmac_key" BLOB NOT NULL, + -- The number of 30 day periods since epoch + "thirty_day_periods_since_epoch" INT NOT NULL, + PRIMARY KEY ("group_id", "hmac_key") +); diff --git a/xmtp_mls/src/storage/encrypted_store/schema.rs b/xmtp_mls/src/storage/encrypted_store/schema.rs index 5a6e3385b..6201e80be 100644 --- a/xmtp_mls/src/storage/encrypted_store/schema.rs +++ b/xmtp_mls/src/storage/encrypted_store/schema.rs @@ -58,6 +58,15 @@ diesel::table! { } } +diesel::table! { + hmac_key_records (group_id, hmac_key) { + group_id -> Binary, + dm_id -> Nullable, + hmac_key -> Binary, + thirty_day_periods_since_epoch -> Integer, + } +} + diesel::table! { identity (rowid) { inbox_id -> Text, @@ -123,6 +132,7 @@ diesel::allow_tables_to_appear_in_same_query!( group_intents, group_messages, groups, + hmac_key_records, identity, identity_updates, key_package_history,