money without backwards compatibility2

This commit is contained in:
Priec
2026-07-12 22:29:22 +02:00
parent 68f0dc7b24
commit ca1bbf84fb
4 changed files with 18 additions and 32 deletions

View File

@@ -169,10 +169,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
".komp_ac.table_definition.AddTableColumnsRequest",
"#[derive(serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
".komp_ac.table_definition.MoneyColumnOptions",
"#[derive(serde::Serialize, serde::Deserialize)]",
)
.type_attribute(
".komp_ac.table_definition.TableDefinitionResponse",
"#[derive(serde::Serialize, serde::Deserialize)]"

View File

@@ -78,9 +78,8 @@ message PostTableDefinitionRequest {
// like "public", "information_schema", or ones starting with "pg_".
string profile_name = 5;
// ISO-4217 base currency used by every MONEY column in this table.
string base_currency = 6;
repeated MoneyColumnOptions money_columns = 7;
}
// Defines append-only column additions for an existing table.
@@ -97,8 +96,8 @@ message AddTableColumnsRequest {
// Optional indexes for the new columns only.
repeated string indexes = 4;
repeated MoneyColumnOptions money_columns = 5;
string base_currency = 6;
// Required when adding the first MONEY column to a table.
string base_currency = 5;
}
@@ -107,12 +106,6 @@ enum MoneyRounding {
MONEY_ROUNDING_HALF_UP = 1;
}
message MoneyColumnOptions {
string column_name = 1;
bool immutable = 2;
MoneyRounding rounding = 3;
}
// Describes one user-defined column for a table.
message ColumnDefinition {
// Column name that follows the same validation rules as table_name.
@@ -132,6 +125,12 @@ message ColumnDefinition {
// DECIMAL args must be integers (no sign, no dot, no leading zeros);
// s ≤ p and p ≥ 1.
string field_type = 2;
// Once initially stored, this column can never be changed.
bool immutable = 3;
// MONEY rounding applied before an immutable value is initially stored.
MoneyRounding rounding = 4;
}
// Response after table creation (success + DDL preview).
@@ -229,7 +228,6 @@ message TableDetail {
repeated ColumnDefinition columns = 3;
repeated ScriptInfo scripts = 4;
string base_currency = 5;
repeated MoneyColumnOptions money_columns = 6;
}
// A script that targets a specific column in a table.

Binary file not shown.

View File

@@ -42,10 +42,9 @@ pub struct PostTableDefinitionRequest {
/// like "public", "information_schema", or ones starting with "pg\_".
#[prost(string, tag = "5")]
pub profile_name: ::prost::alloc::string::String,
/// ISO-4217 base currency used by every MONEY column in this table.
#[prost(string, tag = "6")]
pub base_currency: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "7")]
pub money_columns: ::prost::alloc::vec::Vec<MoneyColumnOptions>,
}
/// Defines append-only column additions for an existing table.
#[derive(serde::Serialize, serde::Deserialize)]
@@ -63,21 +62,10 @@ pub struct AddTableColumnsRequest {
/// Optional indexes for the new columns only.
#[prost(string, repeated, tag = "4")]
pub indexes: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(message, repeated, tag = "5")]
pub money_columns: ::prost::alloc::vec::Vec<MoneyColumnOptions>,
#[prost(string, tag = "6")]
/// Required when adding the first MONEY column to a table.
#[prost(string, tag = "5")]
pub base_currency: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct MoneyColumnOptions {
#[prost(string, tag = "1")]
pub column_name: ::prost::alloc::string::String,
#[prost(bool, tag = "2")]
pub immutable: bool,
#[prost(enumeration = "MoneyRounding", tag = "3")]
pub rounding: i32,
}
/// Describes one user-defined column for a table.
#[derive(serde::Serialize, serde::Deserialize)]
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@@ -100,6 +88,12 @@ pub struct ColumnDefinition {
/// s ≤ p and p ≥ 1.
#[prost(string, tag = "2")]
pub field_type: ::prost::alloc::string::String,
/// Once initially stored, this column can never be changed.
#[prost(bool, tag = "3")]
pub immutable: bool,
/// MONEY rounding applied before an immutable value is initially stored.
#[prost(enumeration = "MoneyRounding", tag = "4")]
pub rounding: i32,
}
/// Response after table creation (success + DDL preview).
#[derive(serde::Serialize, serde::Deserialize)]
@@ -235,8 +229,6 @@ pub struct TableDetail {
pub scripts: ::prost::alloc::vec::Vec<ScriptInfo>,
#[prost(string, tag = "5")]
pub base_currency: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "6")]
pub money_columns: ::prost::alloc::vec::Vec<MoneyColumnOptions>,
}
/// A script that targets a specific column in a table.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]