Skip to main content

toasty_core/schema/db/
ty_enum.rs

1/// A database enum type with a set of allowed values.
2///
3/// - On PostgreSQL, this maps to a `CREATE TYPE <name> AS ENUM (...)` named type.
4/// - On MySQL, this maps to an inline `ENUM('a', 'b', ...)` column type.
5/// - On SQLite, this maps to `TEXT` with a `CHECK` constraint.
6/// - On DynamoDB, this is stored as a plain string attribute.
7#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct TypeEnum {
10    /// The type name used by PostgreSQL (`CREATE TYPE <name> AS ENUM`).
11    /// `None` for MySQL (inline) and SQLite (CHECK constraint).
12    pub name: Option<String>,
13    /// Allowed values in declaration order.
14    pub variants: Vec<EnumVariant>,
15}
16
17/// A single variant in a database enum type.
18#[derive(Debug, Clone, PartialEq)]
19#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
20pub struct EnumVariant {
21    /// The string label for this variant (e.g. `'low'`).
22    pub name: String,
23}