Drop table
The droptable method removes one or more tables from the database, together with their data and indexes.
Usage
droptable is a version-level key that sits next to createtable and altertable. It takes an array of table names.
{
"_id": "1.4.0",
"droptable": ["sessions", "audit_log"]
}Each name compiles to DROP TABLE <name>;, in the order given.
Tables referenced by a foreign key
A table that another table references through a foreign key can not be dropped. Drop the referencing table first, or remove the foreign key with drop_foreign_key in an earlier version.
{
"_id": "1.4.0",
"droptable": ["order_items", "orders"]
}Here order_items references orders, so it is listed first.
Creating a table again
droptable is applied before the other methods of its version, so a table can be dropped and created again in the same version or in a later one.
{
"_id": "1.5.0",
"droptable": ["sessions"],
"createtable": {
"sessions": {
"primary_key": "id",
"id": { "type": "INT", "a_i": true },
"token": { "type": "VARCHAR", "length": 64 }
}
}
}The new table starts from scratch. Columns, primary key and renames from before the drop do not carry over to it.
Consolidation
A dropped table is left out of a consolidated version source. A table that was dropped and created again is consolidated from the version that dropped it.
Verification
Verification reports a critical issue when droptable names a table that does not exist at that version, and a low issue when the array is empty.