Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create/Migrate signed_entity store #858

Merged
merged 7 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mithril-aggregator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-aggregator"
version = "0.2.48"
version = "0.2.49"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
34 changes: 34 additions & 0 deletions mithril-aggregator/src/database/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,40 @@ insert into signer_registration (signer_id,
left join stake_pool on stake_pool.stake_pool_id = verification_key_signer.key and stake_pool.epoch = verification_key.key
order by verification_key.key, verification_key_signer.key asc;
drop table verification_key;
"#,
),
// Migration 7
// Add the `signed_entity` table and migration data from the previous
// `snapshot` JSON format.
SqlMigration::new(
7,
r#"
create table signed_entity (
signed_entity_id text not null,
signed_entity_type_id integer not null,
certificate_id text not null,
beacon json not null,
entity json not null,
created_at text not null default current_timestamp,
primary key (signed_entity_id)
foreign key (signed_entity_type_id) references signed_entity_type(signed_entity_type_id)
foreign key (certificate_id) references certificate(certificate_id)
);
create table if not exists snapshot (key_hash text primary key, key json not null, value json not null);
insert into signed_entity (signed_entity_id,
signed_entity_type_id,
certificate_id,
beacon,
entity)
select
json_extract(snapshot.value, '$.digest') as signed_entity_id,
2 as signed_entity_type_id,
json_extract(snapshot.value, '$.certificate_hash') as certificate_id,
json_extract(snapshot.value, '$.beacon') as beacon,
snapshot.value as entity
from snapshot
order by ROWID asc;
drop table snapshot;
"#,
),
]
Expand Down
2 changes: 2 additions & 0 deletions mithril-aggregator/src/database/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
mod certificate;
mod epoch_setting;
mod open_message;
mod signed_entity;
mod signer_registration;
mod stake_pool;

pub use certificate::*;
pub use epoch_setting::*;
pub use open_message::*;
pub use signed_entity::*;
pub use signer_registration::*;
pub use stake_pool::*;
Loading