mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
Compare commits
1
Commits
release/0.7.2
...
v0.7.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2715170622 |
No files matched your search
Generated
+3
-3
@@ -586,7 +586,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coa-core"
|
name = "coa-core"
|
||||||
version = "0.7.2"
|
version = "0.7.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -634,7 +634,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coa-release"
|
name = "coa-release"
|
||||||
version = "0.7.2"
|
version = "0.7.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"coa-core",
|
"coa-core",
|
||||||
@@ -643,7 +643,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coa-server-manager"
|
name = "coa-server-manager"
|
||||||
version = "0.7.2"
|
version = "0.7.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"coa-control-proto",
|
"coa-control-proto",
|
||||||
"coa-core",
|
"coa-core",
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ members = ["crates/coa-core", "crates/coa-release", "crates/coa-registry-proto",
|
|||||||
exclude = ["services/coa-registry", "services/coa-registry-e2e", "services/coa-coordinator", "services/coa-relay"]
|
exclude = ["services/coa-registry", "services/coa-registry-e2e", "services/coa-coordinator", "services/coa-relay"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.7.2"
|
version = "0.7.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "AGPL-3.0-only"
|
license = "AGPL-3.0-only"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
area: manager
|
||||||
|
type: fixed
|
||||||
|
audience: players
|
||||||
|
title: Portable characters open again after using an experimental Manager
|
||||||
|
---
|
||||||
|
Preserves saved characters and collections when opening a portable store upgraded by an experimental Manager.
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
-- Schema 9: Multi-ruleset partitioned collections and reborn ruleset support.
|
||||||
|
-- 1. Partition collection table by (profile_id, ruleset, kind)
|
||||||
|
CREATE TABLE collection_new (
|
||||||
|
profile_id TEXT NOT NULL REFERENCES profile(profile_id),
|
||||||
|
ruleset TEXT NOT NULL CHECK (ruleset IN ('coa', 'wildcard', 'reborn')),
|
||||||
|
kind TEXT NOT NULL,
|
||||||
|
collection_revision INTEGER NOT NULL CHECK (collection_revision >= 1),
|
||||||
|
collection_hash BLOB NOT NULL CHECK (length(collection_hash) = 32),
|
||||||
|
format_version INTEGER NOT NULL,
|
||||||
|
item_count INTEGER NOT NULL,
|
||||||
|
updated_at TEXT NOT NULL,
|
||||||
|
payload BLOB NOT NULL,
|
||||||
|
PRIMARY KEY (profile_id, ruleset, kind)
|
||||||
|
) STRICT;
|
||||||
|
|
||||||
|
INSERT INTO collection_new (profile_id, ruleset, kind, collection_revision, collection_hash, format_version, item_count, updated_at, payload)
|
||||||
|
SELECT profile_id, 'coa', kind, collection_revision, collection_hash, format_version, item_count, updated_at, payload
|
||||||
|
FROM collection;
|
||||||
|
|
||||||
|
DROP TABLE collection;
|
||||||
|
ALTER TABLE collection_new RENAME TO collection;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS character_profile_ruleset ON character(profile_id, ruleset);
|
||||||
@@ -27,6 +27,7 @@ const MIGRATIONS: &[&str] = &[
|
|||||||
include_str!("migrations/006_collections.sql"),
|
include_str!("migrations/006_collections.sql"),
|
||||||
include_str!("migrations/007_capabilities.sql"),
|
include_str!("migrations/007_capabilities.sql"),
|
||||||
include_str!("migrations/008_projection.sql"),
|
include_str!("migrations/008_projection.sql"),
|
||||||
|
include_str!("migrations/009_multiruleset.sql"),
|
||||||
];
|
];
|
||||||
|
|
||||||
pub const DEFAULT_HISTORY_KEEP: u32 = 20;
|
pub const DEFAULT_HISTORY_KEEP: u32 = 20;
|
||||||
@@ -657,6 +658,7 @@ impl Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- collections ----------------------------------------------------------------------------------------
|
// ---- collections ----------------------------------------------------------------------------------------
|
||||||
|
// These APIs exchange CoA collections only. Preserve other schema-9 partitions without reading or modifying them.
|
||||||
|
|
||||||
/// `stored = stored U incoming`. Nothing is ever removed. When the union equals what is stored, no revision is
|
/// `stored = stored U incoming`. Nothing is ever removed. When the union equals what is stored, no revision is
|
||||||
/// created and the hash stays the same.
|
/// created and the hash stays the same.
|
||||||
@@ -701,9 +703,9 @@ impl Store {
|
|||||||
let payload = merged.encode();
|
let payload = merged.encode();
|
||||||
let at = now();
|
let at = now();
|
||||||
tx.execute(
|
tx.execute(
|
||||||
"INSERT INTO collection(profile_id, kind, collection_revision, collection_hash, format_version, item_count, updated_at, payload)
|
"INSERT INTO collection(profile_id, ruleset, kind, collection_revision, collection_hash, format_version, item_count, updated_at, payload)
|
||||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)
|
VALUES (?1, 'coa', ?2, ?3, ?4, ?5, ?6, ?7, ?8)
|
||||||
ON CONFLICT(profile_id, kind) DO UPDATE SET collection_revision = excluded.collection_revision, collection_hash = excluded.collection_hash,
|
ON CONFLICT(profile_id, ruleset, kind) DO UPDATE SET collection_revision = excluded.collection_revision, collection_hash = excluded.collection_hash,
|
||||||
format_version = excluded.format_version, item_count = excluded.item_count, updated_at = excluded.updated_at, payload = excluded.payload",
|
format_version = excluded.format_version, item_count = excluded.item_count, updated_at = excluded.updated_at, payload = excluded.payload",
|
||||||
params![profile.to_string(), kind, (revision + 1) as i64, hash.as_slice(), PORTABLE_COLLECTION_FORMAT_VERSION, merged.len() as i64, at, payload],
|
params![profile.to_string(), kind, (revision + 1) as i64, hash.as_slice(), PORTABLE_COLLECTION_FORMAT_VERSION, merged.len() as i64, at, payload],
|
||||||
)?;
|
)?;
|
||||||
@@ -730,7 +732,7 @@ impl Store {
|
|||||||
let row = self
|
let row = self
|
||||||
.conn
|
.conn
|
||||||
.query_row(
|
.query_row(
|
||||||
"SELECT collection_revision, collection_hash, item_count, updated_at FROM collection WHERE profile_id = ?1 AND kind = ?2",
|
"SELECT collection_revision, collection_hash, item_count, updated_at FROM collection WHERE profile_id = ?1 AND ruleset = 'coa' AND kind = ?2",
|
||||||
params![profile.to_string(), kind],
|
params![profile.to_string(), kind],
|
||||||
|r| Ok((r.get::<_, i64>(0)?, r.get::<_, Vec<u8>>(1)?, r.get::<_, i64>(2)?, r.get::<_, String>(3)?)),
|
|r| Ok((r.get::<_, i64>(0)?, r.get::<_, Vec<u8>>(1)?, r.get::<_, i64>(2)?, r.get::<_, String>(3)?)),
|
||||||
)
|
)
|
||||||
@@ -780,7 +782,7 @@ fn read_collection(
|
|||||||
) -> Result<Option<(CollectionInfo, IdSet)>> {
|
) -> Result<Option<(CollectionInfo, IdSet)>> {
|
||||||
let row = conn
|
let row = conn
|
||||||
.query_row(
|
.query_row(
|
||||||
"SELECT collection_revision, collection_hash, item_count, updated_at, payload FROM collection WHERE profile_id = ?1 AND kind = ?2",
|
"SELECT collection_revision, collection_hash, item_count, updated_at, payload FROM collection WHERE profile_id = ?1 AND ruleset = 'coa' AND kind = ?2",
|
||||||
params![profile.to_string(), kind],
|
params![profile.to_string(), kind],
|
||||||
|r| Ok((r.get::<_, i64>(0)?, r.get::<_, Vec<u8>>(1)?, r.get::<_, i64>(2)?, r.get::<_, String>(3)?, r.get::<_, Vec<u8>>(4)?)),
|
|r| Ok((r.get::<_, i64>(0)?, r.get::<_, Vec<u8>>(1)?, r.get::<_, i64>(2)?, r.get::<_, String>(3)?, r.get::<_, Vec<u8>>(4)?)),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,6 +7,101 @@ fn fresh() -> (Store, ProfileId) {
|
|||||||
(store, profile)
|
(store, profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn schema_nine_upgrade_preserves_characters_and_isolates_collections() {
|
||||||
|
let dir = tempfile::tempdir().unwrap();
|
||||||
|
let conn = Connection::open(Store::path_of(dir.path())).unwrap();
|
||||||
|
for sql in &MIGRATIONS[..8] {
|
||||||
|
conn.execute_batch(sql).unwrap();
|
||||||
|
}
|
||||||
|
conn.pragma_update(None, "application_id", APPLICATION_ID)
|
||||||
|
.unwrap();
|
||||||
|
conn.pragma_update(None, "user_version", 8).unwrap();
|
||||||
|
let mut old = Store { conn };
|
||||||
|
let profile = old.default_profile().unwrap();
|
||||||
|
let id = created(&mut old, profile);
|
||||||
|
old.bind_server(id, "realm-a", 42, 1, MappingState::Synced)
|
||||||
|
.unwrap();
|
||||||
|
let before = old.load_current(id).unwrap();
|
||||||
|
let set = IdSet::from_ids([10, 20]).unwrap();
|
||||||
|
let kind = "coa:wardrobe";
|
||||||
|
old.conn
|
||||||
|
.execute(
|
||||||
|
"INSERT INTO collection VALUES (?1, ?2, 7, ?3, ?4, 2, 'before', ?5)",
|
||||||
|
params![
|
||||||
|
profile.to_string(),
|
||||||
|
kind,
|
||||||
|
set.hash(kind).as_slice(),
|
||||||
|
PORTABLE_COLLECTION_FORMAT_VERSION,
|
||||||
|
set.encode()
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
drop(old);
|
||||||
|
|
||||||
|
let mut store = Store::open(dir.path()).unwrap();
|
||||||
|
assert_eq!(store.schema_version().unwrap(), 9);
|
||||||
|
assert_eq!(store.load_current(id).unwrap(), before);
|
||||||
|
assert_eq!(store.server_mappings(id).unwrap()[0].local_guid, 42);
|
||||||
|
assert_eq!(store.collection(profile, kind).unwrap().unwrap().1, set);
|
||||||
|
assert_eq!(
|
||||||
|
store
|
||||||
|
.collection_info(profile, kind)
|
||||||
|
.unwrap()
|
||||||
|
.unwrap()
|
||||||
|
.revision,
|
||||||
|
7
|
||||||
|
);
|
||||||
|
// An experimental Manager may already have populated another partition.
|
||||||
|
store.conn.execute(
|
||||||
|
"INSERT INTO collection SELECT profile_id, 'reborn', kind, collection_revision, collection_hash, format_version, item_count, updated_at, payload FROM collection WHERE ruleset = 'coa'",
|
||||||
|
[],
|
||||||
|
).unwrap();
|
||||||
|
store
|
||||||
|
.merge_collection(profile, kind, &IdSet::from_ids([30]).unwrap())
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
store.collection(profile, kind).unwrap().unwrap().1,
|
||||||
|
IdSet::from_ids([10, 20, 30]).unwrap()
|
||||||
|
);
|
||||||
|
let foreign: (i64, Vec<u8>) = store
|
||||||
|
.conn
|
||||||
|
.query_row(
|
||||||
|
"SELECT collection_revision, payload FROM collection WHERE ruleset = 'reborn'",
|
||||||
|
[],
|
||||||
|
|r| Ok((r.get(0)?, r.get(1)?)),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(foreign, (7, set.encode()));
|
||||||
|
drop(store);
|
||||||
|
assert_eq!(
|
||||||
|
Store::open(dir.path()).unwrap().load_current(id).unwrap(),
|
||||||
|
before
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[ignore = "Requires a disposable SQLite backup in COA_PORTABLE_SCHEMA9_FIXTURE"]
|
||||||
|
fn schema_nine_existing_store_and_runtime_smoke() {
|
||||||
|
let root = std::path::PathBuf::from(
|
||||||
|
std::env::var_os("COA_PORTABLE_SCHEMA9_FIXTURE").expect("fixture path"),
|
||||||
|
);
|
||||||
|
for role in ["owner", "host"] {
|
||||||
|
let store = Store::open(&root.join(role)).unwrap();
|
||||||
|
assert_eq!(store.schema_version().unwrap(), 9);
|
||||||
|
let records = store.list_characters_all().unwrap();
|
||||||
|
assert!(!records.is_empty());
|
||||||
|
for record in records {
|
||||||
|
store.load_current(record.character_id).unwrap();
|
||||||
|
store.list_revisions(record.character_id).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let runtime =
|
||||||
|
crate::portable::service::PortableRuntime::start(&root, Box::new(Vec::new), None).unwrap();
|
||||||
|
runtime.call(|_| ()).unwrap();
|
||||||
|
runtime.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
fn created(store: &mut Store, profile: ProfileId) -> CharacterId {
|
fn created(store: &mut Store, profile: ProfileId) -> CharacterId {
|
||||||
store
|
store
|
||||||
.create_character(profile, fixtures::geared_level_eighty(), "realm-a")
|
.create_character(profile, fixtures::geared_level_eighty(), "realm-a")
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "coa-server-manager",
|
"name": "coa-server-manager",
|
||||||
"version": "0.7.2",
|
"version": "0.7.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coa-server-manager",
|
"name": "coa-server-manager",
|
||||||
"version": "0.7.2",
|
"version": "0.7.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": "^2.12.0",
|
"@tauri-apps/api": "^2.12.0",
|
||||||
"@tauri-apps/plugin-dialog": "^2.8.0",
|
"@tauri-apps/plugin-dialog": "^2.8.0",
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "coa-server-manager",
|
"name": "coa-server-manager",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.7.2",
|
"version": "0.7.3",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "CoA Server Manager",
|
"productName": "CoA Server Manager",
|
||||||
"version": "0.7.2",
|
"version": "0.7.3",
|
||||||
"identifier": "com.coa.servermanager",
|
"identifier": "com.coa.servermanager",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|||||||
Reference in new issue
Block a user