datajoint / datajoint-python

Relational data pipelines for the science lab
https://datajoint.com/docs
GNU Lesser General Public License v2.1
169 stars 84 forks source link

dropping shadowed tables #330

Open dimitri-yatsenko opened 7 years ago

dimitri-yatsenko commented 7 years ago

On several occasions, we ended up in a situation where a new table is created with a different tier while an old table for the same class exists with a different tier. DataJoint does not handle this gracefully because it cannot create class for the shadowed table. Both spawn_missing_classes and create_virtual_module raise an error when then run into the situation.

The problem is exacerbated by DataJoint's readiness to create a new table when another table for the same class name already exists.

I propose to prohibit creating a new table if another table for the same class (but a different tier) already exists.

If for any reason, this situation still arises, DataJoint should provide instructions how to delete the shadowed tables using dj.FreeRelation.

eywalker commented 7 years ago

I like and agree that we should prohibit creation of the shadowed table but I'm not sure about exposing FreeRelation to the user. That class is meant only for internal usage and I would much rather extend spawn_missing_classes to provide class for the duplicate so that the user can use to delete the unwanted table.