Skip to content

Commit

Permalink
Merge pull request #1005 from input-output-hk/djo/946/fix_datetime_mi…
Browse files Browse the repository at this point in the history
…gration

Fix rfc3339 datetime migration
  • Loading branch information
Alenar authored Jun 22, 2023
2 parents 44dd2ed + 34469cb commit 8be00a9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
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.3.35"
version = "0.3.36"
description = "A Mithril Aggregator server"
authors = { workspace = true }
edition = { workspace = true }
Expand Down
57 changes: 42 additions & 15 deletions mithril-aggregator/src/database/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 8be00a9

Please sign in to comment.