Skip to content

Commit 80158cb

Browse files
committed
Rename 'entity' field to 'artifact' in SignedEntityRecord
1 parent 8b5944a commit 80158cb

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

mithril-aggregator/src/artifact_builder/artifact_builder_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl ArtifactBuilderService for MithrilArtifactBuilderService {
9191
signed_entity_id: artifact.get_id(),
9292
signed_entity_type,
9393
certificate_id: certificate.hash.clone(),
94-
entity: serde_json::to_string(&artifact)?,
94+
artifact: serde_json::to_string(&artifact)?,
9595
created_at: format!("{:?}", Utc::now()),
9696
};
9797

mithril-aggregator/src/database/migration.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,16 @@ drop table single_signature_legacy;
290290
alter table open_message drop column message;
291291
alter table open_message add column protocol_message json not null;
292292
alter table open_message add column is_certified bool not null default false;
293+
"#,
294+
),
295+
// Migration 11
296+
// Alter `signed_entity` table
297+
SqlMigration::new(
298+
11,
299+
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;
293303
"#,
294304
),
295305
]

mithril-aggregator/src/database/provider/signed_entity.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ pub struct SignedEntityRecord {
3232
/// Certificate id for this signed entity.
3333
pub certificate_id: String,
3434

35-
/// Raw signed entity (in JSON format).
36-
pub entity: String,
35+
/// Raw artifact (in JSON format).
36+
pub artifact: String,
3737

3838
/// Date and time when the signed_entity was created
3939
pub created_at: String,
@@ -46,15 +46,15 @@ impl From<Snapshot> for SignedEntityRecord {
4646
signed_entity_id: other.digest,
4747
signed_entity_type: SignedEntityType::CardanoImmutableFilesFull(other.beacon),
4848
certificate_id: other.certificate_hash,
49-
entity,
49+
artifact: entity,
5050
created_at: other.created_at,
5151
}
5252
}
5353
}
5454

5555
impl From<SignedEntityRecord> for Snapshot {
5656
fn from(other: SignedEntityRecord) -> Snapshot {
57-
serde_json::from_str(&other.entity).unwrap()
57+
serde_json::from_str(&other.artifact).unwrap()
5858
}
5959
}
6060

@@ -67,7 +67,7 @@ impl SqLiteEntity for SignedEntityRecord {
6767
let signed_entity_type_id_int = row.get::<i64, _>(1);
6868
let certificate_id = row.get::<String, _>(2);
6969
let beacon_str = row.get::<String, _>(3);
70-
let entity_str = row.get::<String, _>(4);
70+
let artifact_str = row.get::<String, _>(4);
7171
let created_at = row.get::<String, _>(5);
7272

7373
let signed_entity_record = Self {
@@ -81,7 +81,7 @@ impl SqLiteEntity for SignedEntityRecord {
8181
&beacon_str,
8282
)?,
8383
certificate_id,
84-
entity: entity_str,
84+
artifact: artifact_str,
8585
created_at,
8686
};
8787

@@ -102,7 +102,7 @@ impl SqLiteEntity for SignedEntityRecord {
102102
),
103103
("certificate_id", "{:signed_entity:}.certificate_id", "text"),
104104
("beacon", "{:signed_entity:}.beacon", "text"),
105-
("entity", "{:signed_entity:}.entity", "text"),
105+
("artifact", "{:signed_entity:}.artifact", "text"),
106106
("created_at", "{:signed_entity:}.created_at", "text"),
107107
])
108108
}
@@ -201,13 +201,13 @@ impl<'conn> InsertSignedEntityRecordProvider<'conn> {
201201

202202
fn get_insert_condition(&self, signed_entity_record: SignedEntityRecord) -> WhereCondition {
203203
WhereCondition::new(
204-
"(signed_entity_id, signed_entity_type_id, certificate_id, beacon, entity, created_at) values (?*, ?*, ?*, ?*, ?*, ?*)",
204+
"(signed_entity_id, signed_entity_type_id, certificate_id, beacon, artifact, created_at) values (?*, ?*, ?*, ?*, ?*, ?*)",
205205
vec![
206206
Value::String(signed_entity_record.signed_entity_id),
207207
Value::Integer(signed_entity_record.signed_entity_type.index() as i64),
208208
Value::String(signed_entity_record.certificate_id),
209209
Value::String(signed_entity_record.signed_entity_type.get_json_beacon().unwrap()),
210-
Value::String(signed_entity_record.entity),
210+
Value::String(signed_entity_record.artifact),
211211
Value::String(signed_entity_record.created_at),
212212
],
213213
)
@@ -380,7 +380,7 @@ mod tests {
380380
snapshot.beacon,
381381
),
382382
certificate_id: snapshot.certificate_hash,
383-
entity,
383+
artifact: entity,
384384
created_at: snapshot.created_at,
385385
}
386386
})
@@ -432,7 +432,7 @@ mod tests {
432432
)
433433
.unwrap();
434434
statement
435-
.bind(5, signed_entity_record.entity.as_str())
435+
.bind(5, signed_entity_record.artifact.as_str())
436436
.unwrap();
437437
statement
438438
.bind(6, signed_entity_record.created_at.as_str())
@@ -461,7 +461,7 @@ mod tests {
461461
let aliases = SourceAlias::new(&[("{:signed_entity:}", "se")]);
462462

463463
assert_eq!(
464-
"se.signed_entity_id as signed_entity_id, se.signed_entity_type_id as signed_entity_type_id, se.certificate_id as certificate_id, se.beacon as beacon, se.entity as entity, se.created_at as created_at"
464+
"se.signed_entity_id as signed_entity_id, se.signed_entity_type_id as signed_entity_type_id, se.certificate_id as certificate_id, se.beacon as beacon, se.artifact as artifact, se.created_at as created_at"
465465
.to_string(),
466466
projection.expand(aliases)
467467
);
@@ -507,7 +507,7 @@ mod tests {
507507
let (values, params) = condition.expand();
508508

509509
assert_eq!(
510-
"(signed_entity_id, signed_entity_type_id, certificate_id, beacon, entity, created_at) values (?1, ?2, ?3, ?4, ?5, ?6)".to_string(),
510+
"(signed_entity_id, signed_entity_type_id, certificate_id, beacon, artifact, created_at) values (?1, ?2, ?3, ?4, ?5, ?6)".to_string(),
511511
values
512512
);
513513
assert_eq!(
@@ -521,7 +521,7 @@ mod tests {
521521
.get_json_beacon()
522522
.unwrap()
523523
),
524-
Value::String(signed_entity_record.entity),
524+
Value::String(signed_entity_record.artifact),
525525
Value::String(signed_entity_record.created_at),
526526
],
527527
params

0 commit comments

Comments
 (0)