You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P0][bug] handleSave runs multi-statement ALTER as a single executeQuery call — partial apply, no transaction, no read-only, no production-safety confirm #379
src/components/designer/TableDesigner.tsx:208-225 (handleSave) calls generateAlterTable which returns a string with multiple ALTER TABLE statements separated by \n\n. api.executeQuery(connectionId, sql) is called once. MySQL's multi_statement flag splits and executes sequentially. If statement 3 of 5 fails (duplicate-key error, FK violation, syntax error from rename), statements 1-2 are committed — table half-modified. The handler also (a) skips resultStore.executeQuery's production-safety confirm (calls api.executeQuery directly), (b) bypasses read_only profile enforcement (admin F1 pattern), (c) doesn't apply query_timeout_secs (editor F3 — column exists but never enforced), (d) doesn't write a history entry.
If column 3 conflicts (e.g., UNIQUE constraint fails), columns 1-2 are committed
Expected
Either all 5 ALTER statements apply or none do.
Proposed fix
(a) Add a backend command apply_designer_changes(connection_id, database, statements: Vec<String>) -> DesignerResult in commands/mod.rs (or new mas-designer crate) that wraps the statements in sqlx::Transaction<'_, MySql> and commits only on full success. (b) Check profile.read_only and profile.environment === "production"; reject with CoreError::ReadOnlyViolation for read-only; return confirm-prompt payload for production. (c) Wire the frontend to call this command instead of api.executeQuery. (d) Add a separate execute_single_statement command for ALTERs the user wants to run individually (preview path). Scope: L.
Acceptance
A 5-statement ALTER where statement 3 fails leaves the table unchanged (full rollback). Designer against read_only=true profile is rejected. Designer on production with a DROP COLUMN change triggers the confirm dialog. A history entry is written.
Activity
fix(designer): apply schema changes as one statement, not a run of th…
fix(designer): show the CREATE TABLE before running it (#549)