Skip to content

Commit 813faf7

Browse files
authored
Merge pull request #861 from input-output-hk/jpraynaud/814-create-signer-store
Create/Migrate `signer` store
2 parents 66b7a2e + 69043cc commit 813faf7

File tree

10 files changed

+683
-22
lines changed

10 files changed

+683
-22
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.50"
3+
version = "0.2.51"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/database/migration.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ create table open_message (
151151
// Migration 6
152152
// Add the `signer_registration` table and migration data from the previous
153153
// `verification_key` JSON format.
154-
// TODO: activate FK w/ signer table exists `foreign key (signer_id) references signer(signer_id)`
155154
SqlMigration::new(
156155
6,
157156
r#"
@@ -221,6 +220,45 @@ insert into signed_entity (signed_entity_id,
221220
from snapshot
222221
order by ROWID asc;
223222
drop table snapshot;
223+
"#,
224+
),
225+
// Migration 8
226+
// Add the `signer` table and migration data from `signer_registration` table
227+
SqlMigration::new(
228+
8,
229+
r#"
230+
create table signer (
231+
signer_id text not null,
232+
pool_ticker text,
233+
created_at text not null default current_timestamp,
234+
updated_at text not null default current_timestamp,
235+
primary key (signer_id)
236+
);
237+
insert into signer (signer_id, created_at, updated_at)
238+
select
239+
distinct(signer_registration.signer_id) as signer_id,
240+
min(signer_registration.created_at) as created_at,
241+
max(signer_registration.created_at) as updated_at
242+
from signer_registration
243+
group by signer_registration.signer_id
244+
order by signer_registration.signer_id;
245+
246+
alter table signer_registration rename to signer_registration_temp;
247+
create table signer_registration (
248+
signer_id text not null,
249+
epoch_setting_id integer not null,
250+
verification_key text not null,
251+
verification_key_signature text,
252+
operational_certificate text,
253+
kes_period integer,
254+
stake integer,
255+
created_at text not null default current_timestamp,
256+
primary key (epoch_setting_id, signer_id)
257+
foreign key (epoch_setting_id) references epoch_setting(epoch_setting_id)
258+
foreign key (signer_id) references signer(signer_id)
259+
);
260+
insert into signer_registration select * from signer_registration_temp order by ROWID asc;
261+
drop table signer_registration_temp;
224262
"#,
225263
),
226264
]

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ mod certificate;
33
mod epoch_setting;
44
mod open_message;
55
mod signed_entity;
6+
mod signer;
67
mod signer_registration;
78
mod stake_pool;
89

910
pub use certificate::*;
1011
pub use epoch_setting::*;
1112
pub use open_message::*;
1213
pub use signed_entity::*;
14+
pub use signer::*;
1315
pub use signer_registration::*;
1416
pub use stake_pool::*;

0 commit comments

Comments
 (0)