versioning of FK for archiving

This commit is contained in:
Priec
2026-08-11 21:07:21 +02:00
parent 077d69d756
commit dcc07ee708
13 changed files with 529 additions and 11 deletions

View File

@@ -83,6 +83,11 @@ message PostTableDefinitionRequest {
// to individual MONEY-column currencies: tables may hold money in any currency, and amounts convert
// to this one when they reach the ledger.
string accounting_currency = 8;
// When true, the table is stored once in the global physical schema and is
// visible from every profile. profile_name and accounting_currency are ignored.
bool global = 9;
}
// Defines the input for explicitly creating tables backed by one invoice
@@ -237,6 +242,9 @@ message ProfileTreeResponse {
// "dynamic" for user-defined tables, "system" for backend-managed tables.
string table_kind = 5;
// True when this table is shared by every profile.
bool global = 6;
}
// Profile (schema) entry.
@@ -313,6 +321,7 @@ message TableDetail {
repeated string row_display_columns = 6;
map<string, ColumnBehavior> column_behaviors = 7;
string table_kind = 8;
bool global = 9;
}
// Server-owned behavior for one logical column returned in table details.

View File

@@ -47,6 +47,18 @@ service TablesData {
// - Updates the row and returns the id; queues search indexing (best effort)
rpc PutTableData(PutTableDataRequest) returns (PutTableDataResponse);
// Performs a PUT after the user explicitly accepted its cross-profile impact.
// This is meaningful only for global tables; ordinary tables behave exactly
// like PutTableData.
rpc PutTableDataConfirmed(PutTableDataRequest) returns (PutTableDataResponse);
// Lists the other profiles whose rows currently point at this global row.
rpc GetGlobalTableUpdateImpact(GlobalTableUpdateImpactRequest) returns (GlobalTableUpdateImpactResponse);
// Snapshots the current version of a global row and advances its version.
// Existing references remain immutable; new references use the new version.
rpc ArchiveGlobalTableData(ArchiveGlobalTableDataRequest) returns (ArchiveGlobalTableDataResponse);
// Soft-delete a single record (sets deleted = true) if it exists and is not already deleted.
//
// Behavior:
@@ -68,6 +80,9 @@ service TablesData {
// - If the physical table is missing but the definition exists, returns INTERNAL
rpc GetTableData(GetTableDataRequest) returns (GetTableDataResponse);
// Fetches one exact version of a global row.
rpc GetGlobalTableDataVersion(GetGlobalTableDataVersionRequest) returns (GetTableDataResponse);
// Count non-deleted rows in a table.
//
// Behavior:
@@ -214,6 +229,32 @@ message PutTableDataResponse {
int64 row_revision = 4;
}
message GlobalTableUpdateImpactRequest {
string profile_name = 1;
string table_name = 2;
int64 id = 3;
}
message GlobalTableUpdateImpactResponse {
repeated string affected_profiles = 1;
}
message ArchiveGlobalTableDataRequest {
string profile_name = 1;
string table_name = 2;
int64 id = 3;
int64 expected_revision = 4;
}
message ArchiveGlobalTableDataResponse {
bool success = 1;
int64 archived_version = 2;
string archived_at = 3;
repeated string affected_profiles = 4;
int64 current_version = 5;
int64 row_revision = 6;
}
// Soft-delete a single row.
message DeleteTableDataRequest {
// Required. Profile (schema) name.
@@ -245,6 +286,14 @@ message GetTableDataRequest {
// Required. Id of the row to fetch.
int64 id = 3;
}
message GetGlobalTableDataVersionRequest {
string profile_name = 1;
string table_name = 2;
int64 id = 3;
int64 version = 4;
}
// Row payload: all columns returned as strings.
@@ -264,6 +313,9 @@ message GetTableDataResponse {
// identified by its id alone.
repeated string row_display_values = 2;
repeated string row_display_columns = 3;
// Version paired with each global-link column in this row.
map<string, int64> link_versions = 4;
}
// Count non-deleted rows.