Skip to content

Commit e2eca8b

Browse files
authored
Merge pull request #858 from input-output-hk/jpraynaud/816-adapt-signed-entity-stores
Create/Migrate `signed_entity` store
2 parents d1c6af7 + 99552bc commit e2eca8b

File tree

6 files changed

+629
-8
lines changed

6 files changed

+629
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.2.48"
3+
version = "0.2.49"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/database/migration.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,40 @@ insert into signer_registration (signer_id,
187187
left join stake_pool on stake_pool.stake_pool_id = verification_key_signer.key and stake_pool.epoch = verification_key.key
188188
order by verification_key.key, verification_key_signer.key asc;
189189
drop table verification_key;
190+
"#,
191+
),
192+
// Migration 7
193+
// Add the `signed_entity` table and migration data from the previous
194+
// `snapshot` JSON format.
195+
SqlMigration::new(
196+
7,
197+
r#"
198+
create table signed_entity (
199+
signed_entity_id text not null,
200+
signed_entity_type_id integer not null,
201+
certificate_id text not null,
202+
beacon json not null,
203+
entity json not null,
204+
created_at text not null default current_timestamp,
205+
primary key (signed_entity_id)
206+
foreign key (signed_entity_type_id) references signed_entity_type(signed_entity_type_id)
207+
foreign key (certificate_id) references certificate(certificate_id)
208+
);
209+
create table if not exists snapshot (key_hash text primary key, key json not null, value json not null);
210+
insert into signed_entity (signed_entity_id,
211+
signed_entity_type_id,
212+
certificate_id,
213+
beacon,
214+
entity)
215+
select
216+
json_extract(snapshot.value, '$.digest') as signed_entity_id,
217+
2 as signed_entity_type_id,
218+
json_extract(snapshot.value, '$.certificate_hash') as certificate_id,
219+
json_extract(snapshot.value, '$.beacon') as beacon,
220+
snapshot.value as entity
221+
from snapshot
222+
order by ROWID asc;
223+
drop table snapshot;
190224
"#,
191225
),
192226
]

mithril-aggregator/src/database/provider/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
mod certificate;
33
mod epoch_setting;
44
mod open_message;
5+
mod signed_entity;
56
mod signer_registration;
67
mod stake_pool;
78

89
pub use certificate::*;
910
pub use epoch_setting::*;
1011
pub use open_message::*;
12+
pub use signed_entity::*;
1113
pub use signer_registration::*;
1214
pub use stake_pool::*;

0 commit comments

Comments
 (0)