@@ -187,6 +187,37 @@ insert into signer_registration (signer_id,
187
187
left join stake_pool on stake_pool.stake_pool_id = verification_key_signer.key and stake_pool.epoch = verification_key.key
188
188
order by verification_key.key, verification_key_signer.key asc;
189
189
drop table verification_key;
190
+ "# ,
191
+ ) ,
192
+ // Migration 7
193
+ // Add the `signed_entity` table and migration data from the previous
194
+ // `snapshot` JSON format.
195
+ SqlMigration :: new(
196
+ 7 ,
197
+ r#"
198
+ create table signed_entity (
199
+ signed_entity_id text not null,
200
+ signed_entity_type_id integer not null,
201
+ certificate_id text not null,
202
+ entity json not null,
203
+ created_at text not null default current_timestamp,
204
+ primary key (signed_entity_id)
205
+ foreign key (signed_entity_type_id) references signed_entity_type(signed_entity_type_id)
206
+ foreign key (certificate_id) references certificate(certificate_id)
207
+ );
208
+ create table if not exists snapshot (key_hash text primary key, key json not null, value json not null);
209
+ insert into signed_entity (signed_entity_id,
210
+ signed_entity_type_id,
211
+ certificate_id,
212
+ entity)
213
+ select
214
+ json_extract(snapshot.value, '$.digest') as signed_entity_id,
215
+ 2 as signed_entity_type_id,
216
+ json_extract(snapshot.value, '$.certificate_hash') as certificate_id,
217
+ snapshot.value as entity
218
+ from snapshot
219
+ order by ROWID asc;
220
+ drop table snapshot;
190
221
"# ,
191
222
) ,
192
223
]
0 commit comments