pub struct PackTableReplacement {
pub table: &'static str,
pub marker: &'static str,
pub columns: &'static [&'static str],
pub rebuilds: &'static [&'static str],
pub script: &'static str,
}Expand description
A declared rebuild of pack-owned auxiliary tables whose CHECK constraints change
(ADR-028 Amendment A7).
CREATE TABLE IF NOT EXISTS keeps the checks a table was created with, so a pack that widens
one declares the rebuild here. The backend applies it in the transaction that applies the
pack’s schema plan, after the plan’s statements:
- when the stored
CREATE TABLEoftablecontainsmarker, the table already has the new shape: its columns must equalcolumns, or the plan is refused and nothing is rebuilt again; - otherwise
scriptruns, every table inrebuildsmust hold exactly the rows it held before, the plan’s statements run again to recreate the triggers and indexes the script dropped, and the storedCREATE TABLEoftablemust then containmarker.
Any failure rolls the whole transaction back: the store keeps its old shape and the pack does not load. Read-only backends run no replacement. Identifiers use ASCII letters, digits, or underscores and cannot start with a digit.
Fields§
§table: &'static strThe table whose stored CREATE TABLE carries marker. The pack’s schema plan creates it.
marker: &'static strText found in the stored CREATE TABLE of table only once it has the new shape.
columns: &'static [&'static str]The column names of table in the new shape, in order.
rebuilds: &'static [&'static str]Every table the script drops and recreates, table among them. Each keeps its rows.
script: &'static strSQL that rebuilds the tables in rebuilds: create each new table under another name,
copy its rows, drop the old table and rename the new one. A dropped table’s triggers and
indexes go with it; the plan’s statements recreate them.