maybe_rotate

Function maybe_rotate 

Source
pub fn maybe_rotate(conn: &Connection, now_ms: i64) -> Result<Option<String>>
Expand description

Check if the current raw table has rows from a previous day. If so, rename it to raw_YYYYMMDD (the previous day’s date), create a fresh raw table, record the partition, and refresh the raw_all view. Returns the partition name if a rotation happened, None otherwise.

Safe to call at any time (from the maintenance tick). The rotation is a single transaction: rename, create, record, refresh view. A crash between the rename and the view refresh leaves the partition accessible by its explicit name; the next maintenance tick recreates the view.