diff --git a/common/build.rs b/common/build.rs index 323746b..1d71c08 100644 --- a/common/build.rs +++ b/common/build.rs @@ -169,10 +169,6 @@ fn main() -> Result<(), Box> { ".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)]" diff --git a/common/proto/table_definition.proto b/common/proto/table_definition.proto index fd0110a..6ebc2ea 100644 --- a/common/proto/table_definition.proto +++ b/common/proto/table_definition.proto @@ -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. diff --git a/common/src/proto/descriptor.bin b/common/src/proto/descriptor.bin index c1e613a..f13befb 100644 Binary files a/common/src/proto/descriptor.bin and b/common/src/proto/descriptor.bin differ diff --git a/common/src/proto/komp_ac.table_definition.rs b/common/src/proto/komp_ac.table_definition.rs index c7de2fa..705a952 100644 --- a/common/src/proto/komp_ac.table_definition.rs +++ b/common/src/proto/komp_ac.table_definition.rs @@ -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, } /// 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, - #[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, #[prost(string, tag = "5")] pub base_currency: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "6")] - pub money_columns: ::prost::alloc::vec::Vec, } /// A script that targets a specific column in a table. #[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]