Skip to content

Commit 132db72

Browse files
committed
Migrate 'single_signature' table
1 parent 813faf7 commit 132db72

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

mithril-aggregator/src/database/migration.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,26 @@ create table signer_registration (
259259
);
260260
insert into signer_registration select * from signer_registration_temp order by ROWID asc;
261261
drop table signer_registration_temp;
262+
"#,
263+
),
264+
// Migration 9
265+
// Add the `single_signature` table and rename previous table to `single_signature_legacy`
266+
SqlMigration::new(
267+
9,
268+
r#"
269+
create table if not exists single_signature (key_hash text primary key, key json not null, value json not null);
270+
alter table single_signature rename to single_signature_legacy;
271+
create table single_signature (
272+
open_message_id text not null,
273+
signer_id text not null,
274+
registration_epoch_setting_id integer not null,
275+
lottery_indexes json not null,
276+
signature text not null,
277+
created_at text not null default current_timestamp,
278+
primary key (open_message_id, signer_id, registration_epoch_setting_id)
279+
foreign key (open_message_id) references open_message(open_message_id) on delete cascade
280+
foreign key (signer_id, registration_epoch_setting_id) references signer_registration(signer_id, epoch_setting_id)
281+
);
262282
"#,
263283
),
264284
]

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,14 @@ impl DependenciesBuilder {
469469
dyn StoreAdapter<Key = Beacon, Record = HashMap<PartyId, SingleSignatures>>,
470470
> = match self.configuration.environment {
471471
ExecutionEnvironment::Production => {
472-
let adapter =
473-
SQLiteAdapter::new("single_signature", self.get_sqlite_connection().await?)
474-
.map_err(|e| DependenciesBuilderError::Initialization {
475-
message: "Cannot create SQLite adapter for SingleSignatureStore."
476-
.to_string(),
477-
error: Some(e.into()),
478-
})?;
472+
let adapter = SQLiteAdapter::new(
473+
"single_signature_legacy",
474+
self.get_sqlite_connection().await?,
475+
)
476+
.map_err(|e| DependenciesBuilderError::Initialization {
477+
message: "Cannot create SQLite adapter for SingleSignatureStore.".to_string(),
478+
error: Some(e.into()),
479+
})?;
479480

480481
Box::new(adapter)
481482
}

0 commit comments

Comments
 (0)