[LNT] r237110 - Make upgrade_3_to_4 and upgrade_4_to_5 also work on Postgres databases.
Kristof Beyls
kristof.beyls at arm.com
Tue May 12 03:24:20 PDT 2015
Author: kbeyls
Date: Tue May 12 05:24:20 2015
New Revision: 237110
URL: http://llvm.org/viewvc/llvm-project?rev=237110&view=rev
Log:
Make upgrade_3_to_4 and upgrade_4_to_5 also work on Postgres databases.
When creating a new LNT server instance using a postgresql DB server, the creation failed
when running the upgrades, as Postgres seems to require quotes around the table and
column names if the names are not all lowercase.
Modified:
lnt/trunk/lnt/server/db/migrations/upgrade_3_to_4.py
lnt/trunk/lnt/server/db/migrations/upgrade_4_to_5.py
Modified: lnt/trunk/lnt/server/db/migrations/upgrade_3_to_4.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_3_to_4.py?rev=237110&r1=237109&r2=237110&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_3_to_4.py (original)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_3_to_4.py Tue May 12 05:24:20 2015
@@ -15,8 +15,8 @@ def upgrade(engine):
# Add our new column. SQLAlchemy doesn't really support adding a new column to an
# existing table, so instead of requiring SQLAlchemy-Migrate, just execute the raw SQL.
session.connection().execute("""
-ALTER TABLE TestSuiteSampleFields
-ADD COLUMN bigger_is_better INTEGER DEFAULT 0
+ALTER TABLE "TestSuiteSampleFields"
+ADD COLUMN "bigger_is_better" INTEGER DEFAULT 0
""")
session.commit()
Modified: lnt/trunk/lnt/server/db/migrations/upgrade_4_to_5.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/db/migrations/upgrade_4_to_5.py?rev=237110&r1=237109&r2=237110&view=diff
==============================================================================
--- lnt/trunk/lnt/server/db/migrations/upgrade_4_to_5.py (original)
+++ lnt/trunk/lnt/server/db/migrations/upgrade_4_to_5.py Tue May 12 05:24:20 2015
@@ -29,9 +29,9 @@ def upgrade(engine):
session.commit()
# upgrade_3_to_4.py added this column, so it is not in the ORM.
session.connection().execute("""
-UPDATE TestSuiteSampleFields
+UPDATE "TestSuiteSampleFields"
SET bigger_is_better=1
-WHERE name='score'
+WHERE "Name"='score'
""")
session.commit()
@@ -39,8 +39,8 @@ WHERE name='score'
# trying to find out how to do it properly in SQLAlchemy without
# SQLAlchemy-migrate installed.
session.connection().execute("""
-ALTER TABLE NT_Sample
-ADD COLUMN score FLOAT
+ALTER TABLE "NT_Sample"
+ADD COLUMN "score" FLOAT
""")
session.commit()
More information about the llvm-commits
mailing list