Skip to main content

execute_alter_table

Function execute_alter_table 

Source
pub fn execute_alter_table(
    alter: AlterTable,
    db: &mut Database,
) -> Result<String>
Expand description

Executes ALTER TABLE [IF EXISTS] <name> <op>; for one operation per statement. Supports four sub-operations matching SQLite:

  • RENAME TO <new>
  • RENAME COLUMN <old> TO <new>
  • ADD COLUMN <coldef> (NOT NULL requires DEFAULT on a non-empty table; PK / UNIQUE constraints rejected — would need backfill + uniqueness)
  • DROP COLUMN <name> (refuses PK column and only-column)

Multi-operation ALTER (ALTER TABLE foo RENAME TO bar, ADD COLUMN x ...) is rejected; SQLite forbids it too.