[LNT] r309410 - Add migration that drops old FieldChange table

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 11:02:43 PDT 2017


Author: matze
Date: Fri Jul 28 11:02:43 2017
New Revision: 309410

URL: http://llvm.org/viewvc/llvm-project?rev=309410&view=rev
Log:
Add migration that drops old FieldChange table

LNT has switched to FieldChanveV2 a long time ago and the old table
sometimes got in the way by reporting foreignkey violations when
removing data that was still referenced from the old table.

Added:
    lnt/trunk/lnt/server/db/migrations/upgrade_14_to_15.py
Modified:
    lnt/trunk/lnt/server/db/migrations/util.py

Added: lnt/trunk/lnt/server/db/migrations/upgrade_14_to_15.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_14_to_15.py?rev=309410&view=auto
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_14_to_15.py (added)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_14_to_15.py Fri Jul 28 11:02:43 2017
@@ -0,0 +1,16 @@
+# Drop the "FieldChange" tables; they have been deprecated and replaced by
+# "FieldChangeV2" for a long while now (but can still cause trouble when trying
+# to delete old runs that are referenced from a FieldChange entry).
+from lnt.server.db.migrations.util import introspect_table, rename_table
+
+
+def update_testsuite(engine, db_key_name):
+    table_name = '%s_FieldChange' % db_key_name
+    with engine.begin() as trans:
+        table = introspect_table(engine, table_name, autoload=False)
+        table.drop(checkfirst=True)
+
+
+def upgrade(engine):
+    update_testsuite(engine, 'NT')
+    update_testsuite(engine, 'compile')

Modified: lnt/trunk/lnt/server/db/migrations/util.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/util.py?rev=309410&r1=309409&r2=309410&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/util.py (original)
+++ lnt/trunk/lnt/server/db/migrations/util.py Fri Jul 28 11:02:43 2017
@@ -45,13 +45,13 @@ def add_column(engine, table, column):
     add_column.execute(bind=engine)
 
 
-def introspect_table(engine, name):
+def introspect_table(engine, name, autoload=True):
     # type: (sqlalchemy.engine.Engine, str) -> sqlalchemy.Table
     """Create a SQLAlchemy Table from the table name in the current DB.
 
     Used to make a Table object from something already in the DB."""
     md = sqlalchemy.MetaData(engine)
-    target_table = sqlalchemy.Table(name, md, autoload=True)
+    target_table = sqlalchemy.Table(name, md, autoload=autoload)
     return target_table
 
 




More information about the llvm-commits mailing list