rustyroad 1.7.0

Rusty Road is a framework written in Rust that is based on Ruby on Rails. It is designed to provide the familiar conventions and ease of use of Ruby on Rails, while also taking advantage of the performance and efficiency of Rust.
Documentation
//! Planning the start phase of a declarative operation.

mod add;
mod alter;

use super::model::{DropColumn, Operation};
use super::trigger::{Direction, Trigger};
use super::Plan;

/// Builds the start-phase plan for `operation`.
pub(super) fn plan(operation: &Operation, latest_schema: &str) -> Plan {
    match operation {
        Operation::AddColumn(op) => add::plan(op, latest_schema),
        Operation::AlterColumn(op) => alter::plan(op, latest_schema),
        Operation::DropColumn(op) => drop_column(op, latest_schema),
        Operation::Sql(op) => Plan {
            statements: vec![op.up.clone()],
            ..Plan::default()
        },
    }
}

/// Drops a column at completion, keeping it populated until then.
fn drop_column(op: &DropColumn, latest_schema: &str) -> Plan {
    let mut plan = Plan {
        drops: vec![(op.table.clone(), op.column.clone())],
        ..Plan::default()
    };

    // Old readers still select this column, so new writes must keep filling it.
    if let Some(down) = &op.down {
        plan.statements.extend(
            Trigger {
                table: &op.table,
                physical_column: &op.column,
                direction: Direction::Down,
                expression: down,
                latest_schema,
                rewrite: None,
            }
            .install(),
        );
        plan.backfill_tables.push(op.table.clone());
    }

    plan
}