Expand description
Global alias storage (Phase 2). Persists named queries that span
Single / Multi / Pattern table sources in a dedicated
<project_dir or user_dir>/_global.db SQLite file, separate from
per-table <table>.db. Provides lookup with Project → User
precedence and a lossless migration helper from legacy per-table
_aliases storage.
Global alias storage — single-source-of-truth for named queries that
span [SourceSpec::Single] / [SourceSpec::Multi] / [SourceSpec::Pattern]
table sources.
§Phase 2 Storage Layout
- Project scope:
<project_dir>/_global.db(created on demand) - User scope:
<user_dir>/_global.db(created on demand) - Lookup precedence: Project → User. A Project alias with the same
nameoverrides the User alias of the same name. - Both scopes are independent SQLite files sharing the
[
CREATE_GLOBAL_ALIASES_SQL] schema.
_global.db is intentionally separate from per-table <table>.db
files so that:
- one alias can reference multiple tables (Multi / Pattern sources) without owning a per-table SoT;
- user-wide BP aliases survive project deletion;
- project-specific aliases override user defaults transparently.
§Migration from Per-Table _aliases
[GlobalAliasStorage::migrate_from_per_table] performs a lossless,
idempotent transfer of legacy 5-field rows from per-table _aliases
into the project-scope _global_aliases, with sources filled in as
Single(<table_name>) and aggregator = None. Rows already present
in project storage are skipped (INSERT OR IGNORE semantics) so the
migration may safely run on every registry open.
See crates/core/src/aggregator.rs for the [SourceSpec] /
[AliasAggregator] primitives this storage persists.
Structs§
- Alias
Record - A single global alias record.
- Global
Alias Storage - Global alias storage handle. Holds at most two SQLite connections
(project + user), both wrapped in
Arc<Mutex<_>>so thespawn_blockingbody can lock + execute without violatingSend/Syncbounds (rusqlite::Connection is!Send).
Enums§
- Alias
Scope - Scope determines which
_global.db(project or user) is written to. Lookup (alias_get/alias_list) always reads both with project taking precedence on name collisions.
Constants§
- LEGACY_
PER_ TABLE_ ALIASES_ SQL - Per-table legacy DDL — exposed for migration sites that re-create the
_aliasestable on a fresh connection in tests.