datajoint-python icon indicating copy to clipboard operation
datajoint-python copied to clipboard

improve schema-level drop support

Open ixcat opened this issue 7 years ago • 5 comments
trafficstars

from discussion w/@eywalker

it would be nice to have a facility to support recursive deletion across database schemas so that the datajoint schema drop operation doesn't fail if a table in that schema refers to another table in another schema.

e.g. a new version of schema.drop which omprots/drops on a sorted list of all tables and dependencies related to; existing could can become a drop_quick which stays with the current database-schema level of drop.

ixcat avatar Aug 01 '18 21:08 ixcat

table.drop() already cascades through all tabes that you have access to, including those in other schemas. Dropping entire schemas recursively is a rather powerful operation, perhaps too powerful. Prevention of recursive schema drops may be good actually. Dropping an entire schema is already too powerful an operation.

dimitri-yatsenko avatar Dec 03 '18 06:12 dimitri-yatsenko

Cascading drop is actually not perfect now because if two schemas depend on each other, we don't drop it correctly. While it is a powerful feature, it is needed from time to time and we should support it.

eywalker avatar Dec 03 '18 06:12 eywalker

I would even support a feature to not allow dropping schemas before all the tables have been dropped. This way cascading schema drops become unnecessary. cascading schema drops gives too much power because we do not list all tables and their contents when dropping a schema -- it would take a prohibitive amount of time. Even dropping a single schema with tables in it is too fast and dangerous.

dimitri-yatsenko avatar Dec 03 '18 18:12 dimitri-yatsenko

Related to #838 as once it is addressed, you could loop and drop explicitly as a workaround.

guzman-raphael avatar Jan 19 '21 18:01 guzman-raphael

Quick update: I used this function just now and found it to be really useful. It is really powerful and should only be used sparingly.

davidgodinez avatar Aug 04 '21 15:08 davidgodinez