@@ -6,13 +6,17 @@ use mithril_common::database::SqlMigration;
6
6
/// There shall be one migration per database version. There could be several
7
7
/// statements per migration.
8
8
pub fn get_migrations ( ) -> Vec < SqlMigration > {
9
- vec ! [ SqlMigration :: new(
10
- 1 ,
11
- r#"
9
+ vec ! [
10
+ // Migration 1
11
+ // Add the `stake_pool` table and migration data from the previous
12
+ // `stake_store` JSON format.
13
+ SqlMigration :: new(
14
+ 1 ,
15
+ r#"
12
16
create table stake_pool (
13
17
stake_pool_id text not null,
14
18
epoch integer not null,
15
- stake integer not null,
19
+ stake integer not null,
16
20
created_at text not null default current_timestamp,
17
21
primary key (epoch, stake_pool_id)
18
22
);
@@ -26,5 +30,27 @@ insert into stake_pool (epoch, stake_pool_id, stake)
26
30
order by epoch asc;
27
31
drop table stake;
28
32
"# ,
29
- ) ]
33
+ ) ,
34
+ // Migration 2
35
+ // Add the `epoch_setting` table and migration data from the previous
36
+ // `protocol_parameters` JSON format.
37
+ SqlMigration :: new(
38
+ 2 ,
39
+ r#"
40
+ create table epoch_setting (
41
+ epoch_setting_id integer not null,
42
+ protocol_parameters json not null,
43
+ primary key (epoch_setting_id)
44
+ );
45
+ create table if not exists protocol_parameters (key_hash text primary key, key json not null, value json not null);
46
+ insert into epoch_setting (epoch_setting_id, protocol_parameters)
47
+ select
48
+ protocol_parameters.key as epoch_setting_id,
49
+ protocol_parameters.value as protocol_parameters
50
+ from protocol_parameters
51
+ order by key asc;
52
+ drop table protocol_parameters;
53
+ "# ,
54
+ ) ,
55
+ ]
30
56
}
0 commit comments