Check that the media_data tables are empty.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Mon, 2 Apr 2012 12:02:56 +0000 (14:02 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Mon, 2 Apr 2012 12:02:56 +0000 (14:02 +0200)
In the analyzing part also check that the media_data tables
are empty (as expected) before dropping them.

mediagoblin/db/sql/convert.py

index 2a8734f956653af707c426735bef906ace038961..ac64cf8d5ee9c86e0800b97780fc4e542ae02ef2 100644 (file)
@@ -220,14 +220,21 @@ def cleanup_sql_tables(sql_db):
         count = session.query(MediaEntry.media_type). \
             filter_by(media_type=unicode(mt)).count()
         print "  %s: %d entries" % (mt, count)
+
         if count == 0:
+            print "\tAnalyzing tables"
+            for tab in table_list:
+                cnt2 = session.query(tab).count()
+                print "\t  %s: %d entries" % (tab.__tablename__, cnt2)
+                assert cnt2 == 0
+
             print "\tRemoving migration info"
             mi = session.query(MigrationData).filter_by(name=unicode(mt)).one()
             session.delete(mi)
             session.commit()
             session.close()
 
-            print "\tDropping tables %r" % (table_list,)
+            print "\tDropping tables"
             tables = [model.__table__ for model in table_list]
             Base_v0.metadata.drop_all(sql_db.engine, tables=tables)