Skip to main content

easy_sql/database_structs/
alter_table.rs

1use crate::driver::TableField;
2
3/// Single alter-table operation used by the migration procedural macros.
4///
5/// This enum is **not** intended to be constructed manually in user code; the
6/// [`Table`](macro@crate::Table) macro generates these values when compiling migrations.
7///
8/// # ⚠️ API instability
9///
10/// This type is marked as `#[non_exhaustive]` and **will be changed in the
11/// future**. Prefer to rely on the macros instead of matching all variants.
12#[non_exhaustive]
13pub enum AlterTableSingle {
14    /// Rename an existing table.
15    RenameTable { new_table_name: &'static str },
16    /// Add a new column definition to an existing table.
17    AddColumn { column: TableField },
18    /// Rename an existing column.
19    RenameColumn {
20        old_column_name: &'static str,
21        new_column_name: &'static str,
22    },
23}
24
25/// Collection of alter-table operations for a single table.
26///
27/// This struct is used internally by the migration procedural macros; it is
28/// not considered a stable public API. The [`Table`](macro@crate::Table) macro generates these values
29/// as part of migration compilation, so prefer using the macro instead of
30/// constructing this directly.
31pub struct AlterTable {
32    pub table_name: &'static str,
33    pub alters: Vec<AlterTableSingle>,
34}