From a33fead938228b622bd6bad612c55e86d3021d4e Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:10:47 +0200 Subject: [PATCH 1/2] Fix rfc3339 datetime migration The `created_at` & `artifact` columns of the `signed_entity` table were swapped, leading to an error when querying any artifacts. --- mithril-aggregator/src/database/migration.rs | 57 ++++++++++++++------ 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/mithril-aggregator/src/database/migration.rs b/mithril-aggregator/src/database/migration.rs index e474e2b1890..a9982ad3b9b 100644 --- a/mithril-aggregator/src/database/migration.rs +++ b/mithril-aggregator/src/database/migration.rs @@ -369,7 +369,10 @@ create table new_signer ( primary key (signer_id) ); -insert into new_signer select * from signer order by rowid asc; +insert into new_signer (signer_id, pool_ticker, created_at, updated_at) + select signer_id, pool_ticker, strftime('%Y-%m-%dT%H:%M:%fZ', created_at), + strftime('%Y-%m-%dT%H:%M:%fZ', updated_at) + from signer order by rowid asc; drop table signer; alter table new_signer rename to signer; @@ -388,7 +391,12 @@ create table new_signer_registration ( foreign key (epoch_setting_id) references epoch_setting(epoch_setting_id) foreign key (signer_id) references signer(signer_id) ); -insert into new_signer_registration select * from signer_registration order by rowid asc; +insert into new_signer_registration + ( signer_id, epoch_setting_id, verification_key, verification_key_signature, + operational_certificate, kes_period, stake, created_at) + select signer_id, epoch_setting_id, verification_key, verification_key_signature, + operational_certificate, kes_period, stake, strftime('%Y-%m-%dT%H:%M:%fZ', created_at) + from signer_registration order by rowid asc; drop table signer_registration; alter table new_signer_registration rename to signer_registration; @@ -405,7 +413,12 @@ create table new_single_signature ( foreign key (open_message_id) references open_message(open_message_id) on delete cascade foreign key (signer_id, registration_epoch_setting_id) references signer_registration(signer_id, epoch_setting_id) ); -insert into new_single_signature select * from single_signature order by rowid asc; +insert into new_single_signature + ( open_message_id, signer_id, registration_epoch_setting_id, lottery_indexes, signature, + created_at) + select open_message_id, signer_id, registration_epoch_setting_id, lottery_indexes, signature, + strftime('%Y-%m-%dT%H:%M:%fZ', created_at) + from single_signature order by rowid asc; drop table single_signature; alter table new_single_signature rename to single_signature; @@ -424,12 +437,13 @@ create table new_open_message ( foreign key (signed_entity_type_id) references signed_entity_type (signed_entity_type_id) ); -insert into new_open_message (open_message_id, epoch_setting_id, beacon, signed_entity_type_id, - created_at, protocol_message, is_certified) +insert into new_open_message + ( open_message_id, epoch_setting_id, beacon, signed_entity_type_id, + protocol_message, is_certified, + created_at) select open_message_id, epoch_setting_id, beacon, signed_entity_type_id, - strftime('%Y-%m-%dT%H:%M:%fZ', created_at) as created_at, - protocol_message, - is_certified + protocol_message, is_certified, + strftime('%Y-%m-%dT%H:%M:%fZ', created_at) from open_message order by rowid asc; drop table open_message; @@ -456,10 +470,14 @@ create table new_certificate ( foreign key (parent_certificate_id) references certificate(certificate_id) ); insert into new_certificate + ( certificate_id, parent_certificate_id, message, signature, aggregate_verification_key, + epoch, beacon, protocol_version, protocol_parameters, protocol_message, signers, + initiated_at, + sealed_at) select certificate_id, parent_certificate_id, message, signature, aggregate_verification_key, epoch, beacon, protocol_version, protocol_parameters, protocol_message, signers, - strftime('%Y-%m-%dT%H:%M:%fZ', initiated_at) as initiated_at, - strftime('%Y-%m-%dT%H:%M:%fZ', sealed_at) as sealed_at + strftime('%Y-%m-%dT%H:%M:%fZ', initiated_at), + strftime('%Y-%m-%dT%H:%M:%fZ', sealed_at) from certificate order by rowid asc; drop table certificate; @@ -476,8 +494,9 @@ create table new_stake_pool ( primary key (epoch, stake_pool_id) ); -insert into new_stake_pool (stake_pool_id, epoch, stake, created_at) - select stake_pool_id, epoch, stake, strftime('%Y-%m-%dT%H:%M:%fZ', created_at) as created_at +insert into new_stake_pool + ( stake_pool_id, epoch, stake, created_at) + select stake_pool_id, epoch, stake, strftime('%Y-%m-%dT%H:%M:%fZ', created_at) from stake_pool order by rowid asc; drop table stake_pool; @@ -489,13 +508,18 @@ create table new_signed_entity ( signed_entity_type_id integer not null, certificate_id text not null, beacon json not null, - artifact json not null, created_at text not null, + artifact json not null, 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) ); -insert into new_signed_entity select * from signed_entity order by rowid asc; +insert into new_signed_entity + ( signed_entity_id, signed_entity_type_id, certificate_id, beacon, artifact, + created_at) + select signed_entity_id, signed_entity_type_id, certificate_id, beacon, artifact, + strftime('%Y-%m-%dT%H:%M:%fZ', created_at) + from signed_entity order by rowid asc; drop table signed_entity; alter table new_signed_entity rename to signed_entity; @@ -515,7 +539,10 @@ pragma foreign_keys=true; create table if not exists 'db_version' (application_type text not null primary key, version integer not null, updated_at text not null); create table new_db_version (application_type text not null primary key, version integer not null, updated_at text not null); -insert into new_db_version select * from db_version order by rowid asc; +insert into new_db_version + ( application_type, version, updated_at) + select application_type, version, updated_at + from db_version order by rowid asc; drop table db_version; alter table new_db_version rename to db_version; From 34469cbdc4e8c3319658848332c43926930d0a8d Mon Sep 17 00:00:00 2001 From: DJO <790521+Alenar@users.noreply.github.com> Date: Thu, 22 Jun 2023 15:58:07 +0200 Subject: [PATCH 2/2] Update versions --- mithril-aggregator/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mithril-aggregator/Cargo.toml b/mithril-aggregator/Cargo.toml index 24039ae0b6f..27bd4805203 100644 --- a/mithril-aggregator/Cargo.toml +++ b/mithril-aggregator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mithril-aggregator" -version = "0.3.35" +version = "0.3.36" description = "A Mithril Aggregator server" authors = { workspace = true } edition = { workspace = true }