Skip to content

Commit b129f1a

Browse files
committed
Fix 'signed_entity' table migration
1 parent cbf035d commit b129f1a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

mithril-aggregator/src/database/migration.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,27 @@ alter table open_message add column is_certified bool not null default false;
297297
SqlMigration::new(
298298
11,
299299
r#"
300-
alter table signed_entity add column artifact json not null;
301-
update signed_entity set artifact = entity;
302-
alter table signed_entity drop column entity;
300+
alter table signed_entity rename to signed_entity_old;
301+
create table signed_entity (
302+
signed_entity_id text not null,
303+
signed_entity_type_id integer not null,
304+
certificate_id text not null,
305+
beacon json not null,
306+
artifact json not null,
307+
created_at text not null default current_timestamp,
308+
primary key (signed_entity_id)
309+
foreign key (signed_entity_type_id) references signed_entity_type(signed_entity_type_id)
310+
foreign key (certificate_id) references certificate(certificate_id)
311+
);
312+
insert into signed_entity (signed_entity_id,
313+
signed_entity_type_id,
314+
certificate_id,
315+
beacon,
316+
artifact, created_at)
317+
select signed_entity_id, signed_entity_type_id, certificate_id, beacon, entity, created_at
318+
from signed_entity_old
319+
order by rowid asc;
320+
drop table signed_entity_old;
303321
"#,
304322
),
305323
]

0 commit comments

Comments
 (0)