File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
internal/mithril-persistence/src/database
mithril-aggregator/src/database Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -165,10 +165,10 @@ pub struct SqlMigration {
165
165
166
166
impl SqlMigration {
167
167
/// Create a new SQL migration instance.
168
- pub fn new ( version : DbVersion , alteration : & str ) -> Self {
168
+ pub fn new < T : Into < String > > ( version : DbVersion , alteration : T ) -> Self {
169
169
Self {
170
170
version,
171
- alterations : alteration. to_string ( ) ,
171
+ alterations : alteration. into ( ) ,
172
172
}
173
173
}
174
174
}
Original file line number Diff line number Diff line change 1
1
//! Migration module
2
2
//!
3
+ use mithril_common:: entities:: SignedEntityTypeDiscriminants ;
3
4
use mithril_persistence:: database:: SqlMigration ;
4
5
5
6
/// Get all the migrations required by this version of the software.
@@ -725,5 +726,31 @@ create index single_signature_signer_id_index on single_signature(signer_id);
725
726
create index single_signature_registration_epoch_setting_id_index on single_signature(registration_epoch_setting_id);
726
727
"# ,
727
728
) ,
729
+ // Migration 25
730
+ // Remove Certificate and SignedEntity based on CardanoTransactions since we changed their beacon
731
+ SqlMigration :: new(
732
+ 25 ,
733
+ format!(
734
+ r#"
735
+ -- disable foreign keys since `certificate` and `signed_entity` are linked together
736
+ pragma foreign_keys=false;
737
+
738
+ delete from certificate
739
+ where certificate_id in (
740
+ select s.certificate_id from signed_entity s
741
+ where s.signed_entity_type_id = {}
742
+ );
743
+
744
+ delete from signed_entity
745
+ where signed_entity_type_id = {};
746
+
747
+ -- reenable foreign keys
748
+ pragma foreign_key_check;
749
+ pragma foreign_keys=true;
750
+ "# ,
751
+ SignedEntityTypeDiscriminants :: CardanoTransactions . index( ) ,
752
+ SignedEntityTypeDiscriminants :: CardanoTransactions . index( )
753
+ ) ,
754
+ ) ,
728
755
]
729
756
}
You can’t perform that action at this time.
0 commit comments