Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f1287f4
[bfops/smoketest-upgrade]: add test
bfops Feb 16, 2026
d378641
[bfops/smoketest-upgrade]: WIP
bfops Feb 16, 2026
a94ed46
[bfops/fix-version-check]: Do thing
bfops Feb 16, 2026
f058942
[bfops/smoketest-upgrade]: Merge remote-tracking branch 'origin/bfops…
bfops Feb 16, 2026
1b650fc
[bfops/smoketest-upgrade]: WIP
bfops Feb 16, 2026
f609483
[bfops/smoketest-upgrade]: update test with debug logs
bfops Feb 17, 2026
2772036
[bfops/smoketest-upgrade]: WIP kill_after_publish_test
bfops Feb 18, 2026
d9a0774
[bfops/smoketest-upgrade]: kill after publish test working
bfops Feb 18, 2026
48adf0e
[bfops/smoketest-upgrade]: WIP
bfops Feb 18, 2026
ef8c6f2
[bfops/smoketest-upgrade]: refactored
bfops Feb 18, 2026
91f1a09
[bfops/smoketest-upgrade]: update
bfops Feb 18, 2026
1f62ee9
[bfops/smoketest-upgrade]: still broken in _working test
bfops Feb 18, 2026
a108354
[bfops/smoketest-upgrade]: still broken in _working
bfops Feb 18, 2026
1096787
[bfops/smoketest-upgrade]: do not upgrade server
bfops Feb 18, 2026
e9436d4
[bfops/smoketest-upgrade]: still broken
bfops Feb 18, 2026
2316fec
[bfops/smoketest-upgrade]: still broken
bfops Feb 18, 2026
64f5db7
[bfops/smoketest-upgrade]: still broken
bfops Feb 18, 2026
b970394
[bfops/smoketest-upgrade]: slimmer
bfops Feb 18, 2026
33584cb
[bfops/smoketest-upgrade]: slimmer
bfops Feb 18, 2026
debe6c3
[bfops/smoketest-upgrade]: clean
bfops Feb 18, 2026
bf0611c
[bfops/smoketest-upgrade]: [bfops/smoketest-upgrade]: optional client…
bfops Feb 18, 2026
d9a249a
[bfops/smoketest-upgrade]: simplify
bfops Feb 18, 2026
4537ef7
[bfops/smoketest-upgrade]: WIP
bfops Feb 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 50 additions & 23 deletions crates/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,56 @@ impl MetadataFile {
path.write(self.to_string())
}

/// Check if this meta file is compatible with the default meta
/// file of a just-started database, and if so return the metadata
/// to write back to the file.
///
/// `self` is the metadata file read from a database, and current is
/// the default metadata file that the active database version would
/// right to a new database.
pub fn check_compatibility_and_update(mut self, current: Self) -> anyhow::Result<Self> {
fn check_compatibility(previous: &Self, current: &Self) -> anyhow::Result<()> {
anyhow::ensure!(
self.edition == current.edition,
previous.edition == current.edition,
"metadata.toml indicates that this database is from a different \
edition of SpacetimeDB (running {:?}, but this database is {:?})",
edition of SpacetimeDB (running {:?}, but this database is {:?})",
current.edition,
self.edition,
previous.edition,
);

// Special-case: SpacetimeDB 2.x can run 1.x databases.
if previous.version.major == 1 && current.version.major == 2 {
return Ok(());
}

let cmp = semver::Comparator {
op: semver::Op::Caret,
major: self.version.major,
minor: Some(self.version.minor),
major: previous.version.major,
minor: Some(previous.version.minor),
patch: None,
pre: self.version.pre.clone(),
pre: previous.version.pre.clone(),
};
anyhow::ensure!(
cmp.matches(&current.version),
"metadata.toml indicates that this database is from a newer, \
incompatible version of SpacetimeDB (running {:?}, but this \
database is from {:?})",

if cmp.matches(&current.version) {
return Ok(());
}

let relation = if previous.version > current.version {
"a newer, incompatible"
} else if previous.version < current.version {
"an older, incompatible"
} else {
"an incompatible"
};
anyhow::bail!(
"metadata.toml indicates that you are running {relation} database. Your running version is {:?}, but the database on disk is from {:?}.",
current.version,
self.version,
previous.version,
);
// bump the version in the file only if it's being run in a newer
// database -- this won't do anything until we release v1.1.0, since we
// set current.version.patch to 0 in Self::new() due to a bug in v1.0.0
}

/// Check if this meta file is compatible with the default meta
/// file of a just-started database, and if so return the metadata
/// to write back to the file.
///
/// `self` is the metadata file read from a database, and current is
/// the default metadata file that the active database version would
/// right to a new database.
pub fn check_compatibility_and_update(mut self, current: Self) -> anyhow::Result<Self> {
Self::check_compatibility(&self, &current)?;
// bump the version in the file only if it's being run in a newer database.
self.version = std::cmp::max(self.version, current.version);
Ok(self)
}
Expand Down Expand Up @@ -184,5 +201,15 @@ mod tests {
mkmeta(2, 0, 0)
.check_compatibility_and_update(mkmeta(1, 3, 5))
.unwrap_err();
assert_eq!(
mkmeta(1, 12, 0)
.check_compatibility_and_update(mkmeta(2, 0, 0))
.unwrap()
.version,
mkver(2, 0, 0)
);
mkmeta(2, 0, 0)
.check_compatibility_and_update(mkmeta(3, 0, 0))
.unwrap_err();
}
}
Loading
Loading