pub fn table(table: &str, f: impl FnOnce(&mut Blueprint)) -> StatementExpand description
Changes an existing table, as Laravel’s Schema::table. A column described in the closure is
added, or modified when it ends with .change(); rename_column and drop_column rename and
drop columns; index, unique, primary and foreign add keys; drop_index and
drop_foreign drop them.
Each operation renders as its own statement on every database, in the order it was called, as
in Laravel 11 and later: t.drop_column("x"); t.string("x"); drops the column and then adds
it again, and t.rename_column("a", "b"); t.string("a"); renames and then adds. PostgreSQL and
SQLite add a plain index with CREATE INDEX and drop one with DROP INDEX, and SQLite adds a
unique index with CREATE UNIQUE INDEX; the rest is ALTER TABLE. SQLite cannot add or drop
a constraint on an existing table: a foreign key and drop_foreign render nothing there, and
a primary key is Error::Unsupported.