Attempt to explain byzantine include_object function
@@ -30,6 +30,10 @@ target_metadata = Base.metadata
def include_object(object, name, type_, reflected, compare_to):
+ """
+ Tells Alembic whether it owns an object. This can be used to exclude
+ objects from autogenerated migrations.
+ """
valid_names = set()
for name, obj in inspect.getmembers(models):
if inspect.isclass(obj):
@@ -37,13 +41,10 @@ def include_object(object, name, type_, reflected, compare_to):
valid_names.add(str(obj.__tablename__))
if type_ == "table":
if str(object) == "image":
- print('discarded', name)
return False
elif str(object) in valid_names:
- print('included', str(object))
return True
else:
- print('discarded', str(object))
return False
else:
return True
