Skip to content

Commit 71d2dfe

Browse files
ldanilekConvex, Inc.
authored andcommitted
remove _modules.latest_version field (#27130)
the `latest_version` field is unused now. and it's optional when parsed, so we can delete it. note the module cache is keyed on source package id now. also while we're here, there's a 3 year old TODO which i checked in db-verifier is already done. GitOrigin-RevId: 79a59bab837dc91f3cbda95a0acad7470eff4825
1 parent 74f1f57 commit 71d2dfe

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

crates/model/src/modules/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ use self::{
5858
AnalyzedFunction,
5959
AnalyzedModule,
6060
ModuleSource,
61-
ModuleVersion,
6261
ModuleVersionMetadata,
6362
SourceMap,
6463
},
@@ -365,15 +364,11 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
365364
analyze_result: Option<AnalyzedModule>,
366365
environment: ModuleEnvironment,
367366
sha256: Sha256Digest,
368-
) -> anyhow::Result<(ResolvedDocumentId, Option<ModuleVersion>)> {
369-
let (module_id, version) = match self.module_metadata(path.clone()).await? {
367+
) -> anyhow::Result<ResolvedDocumentId> {
368+
let module_id = match self.module_metadata(path.clone()).await? {
370369
Some(module_metadata) => {
371-
let previous_version = module_metadata.latest_version;
372-
373-
let latest_version = previous_version.map(|v| v + 1);
374370
let new_metadata = ModuleMetadata {
375371
path: path.module_path,
376-
latest_version,
377372
source_package_id,
378373
environment,
379374
analyze_result: analyze_result.clone(),
@@ -383,26 +378,23 @@ impl<'a, RT: Runtime> ModuleModel<'a, RT> {
383378
.replace(module_metadata.id(), new_metadata.try_into()?)
384379
.await?;
385380

386-
(module_metadata.id(), latest_version)
381+
module_metadata.id()
387382
},
388383
None => {
389-
let version = Some(0);
390384
let new_metadata = ModuleMetadata {
391385
path: path.module_path,
392-
latest_version: version,
393386
source_package_id,
394387
environment,
395388
analyze_result: analyze_result.clone(),
396389
sha256,
397390
};
398391

399-
let document_id = SystemMetadataModel::new(self.tx, path.component.into())
392+
SystemMetadataModel::new(self.tx, path.component.into())
400393
.insert(&MODULES_TABLE, new_metadata.try_into()?)
401-
.await?;
402-
(document_id, version)
394+
.await?
403395
},
404396
};
405-
Ok((module_id, version))
397+
Ok(module_id)
406398
}
407399

408400
/// Delete a module, making it inaccessible for subsequent transactions.

crates/model/src/modules/types.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use value::{
1515

1616
use super::module_versions::{
1717
AnalyzedModule,
18-
ModuleVersion,
1918
SerializedAnalyzedModule,
2019
};
2120
use crate::source_packages::types::SourcePackageId;
@@ -26,8 +25,6 @@ use crate::source_packages::types::SourcePackageId;
2625
pub struct ModuleMetadata {
2726
/// Path stored as a "path" field.
2827
pub path: CanonicalizedModulePath,
29-
/// What is the latest version of the module?
30-
pub latest_version: Option<ModuleVersion>,
3128

3229
pub source_package_id: SourcePackageId,
3330
pub environment: ModuleEnvironment,
@@ -40,7 +37,6 @@ pub struct ModuleMetadata {
4037
#[serde(rename_all = "camelCase")]
4138
pub struct SerializedModuleMetadata {
4239
pub path: String,
43-
pub latest_version: Option<ModuleVersion>,
4440
pub source_package_id: String,
4541
pub environment: String,
4642
pub analyze_result: Option<SerializedAnalyzedModule>,
@@ -54,11 +50,8 @@ impl TryFrom<SerializedModuleMetadata> for ModuleMetadata {
5450
Ok(Self {
5551
path: {
5652
let path: ModulePath = m.path.parse()?;
57-
// TODO: Remove this canonicalization once we've fully backfilled canonicalized
58-
// module paths.
59-
path.canonicalize()
53+
path.assume_canonicalized()?
6054
},
61-
latest_version: m.latest_version,
6255
source_package_id: DeveloperDocumentId::decode(&m.source_package_id)?.into(),
6356
environment: m.environment.parse()?,
6457
analyze_result: m.analyze_result.map(|s| s.try_into()).transpose()?,
@@ -73,7 +66,6 @@ impl TryFrom<ModuleMetadata> for SerializedModuleMetadata {
7366
fn try_from(m: ModuleMetadata) -> anyhow::Result<Self> {
7467
Ok(Self {
7568
path: String::from(m.path),
76-
latest_version: m.latest_version,
7769
source_package_id: DeveloperDocumentId::from(m.source_package_id).to_string(),
7870
environment: m.environment.to_string(),
7971
analyze_result: m.analyze_result.map(|s| s.try_into()).transpose()?,

0 commit comments

Comments
 (0)