From bced1f456d59e9ef67e061b80a0547a0b478bc0a Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Mon, 8 Mar 2010 17:06:34 +0100 Subject: [PATCH] move transaction handling from update_schema to the SQL scripts, as it didn't work. --- pyweb/mumble/admin.py | 1 + pyweb/mumble/conversionsql/pgsql/01-schema-prepare-mumble.sql | 2 ++ .../conversionsql/pgsql/11-data-mumble_mumbleserver.sql | 2 ++ pyweb/mumble/conversionsql/pgsql/12-data-mumble_mumble.sql | 2 ++ pyweb/mumble/conversionsql/pgsql/21-schema-cleanup-mumble.sql | 2 ++ .../conversionsql/pgsql/22-schema-cleanup-mumbleuser.sql | 2 ++ pyweb/mumble/management/update_schema.py | 4 ---- 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pyweb/mumble/admin.py b/pyweb/mumble/admin.py index a31b86b..5a9f6a5 100644 --- a/pyweb/mumble/admin.py +++ b/pyweb/mumble/admin.py @@ -54,6 +54,7 @@ class MumbleAdmin(admin.ModelAdmin): def get_addr( self, obj ): if not obj.addr: return "*" + return obj.addr get_addr.short_description = _('Server Address') diff --git a/pyweb/mumble/conversionsql/pgsql/01-schema-prepare-mumble.sql b/pyweb/mumble/conversionsql/pgsql/01-schema-prepare-mumble.sql index 4063690..77a7f6d 100644 --- a/pyweb/mumble/conversionsql/pgsql/01-schema-prepare-mumble.sql +++ b/pyweb/mumble/conversionsql/pgsql/01-schema-prepare-mumble.sql @@ -1,4 +1,5 @@ -- Model: Mumble +BEGIN; ALTER TABLE "mumble_mumble" ADD "server_id" integer NULL REFERENCES "mumble_mumbleserver" ("id") DEFERRABLE INITIALLY DEFERRED; ALTER TABLE "mumble_mumble" @@ -9,3 +10,4 @@ ALTER TABLE "mumble_mumble" CREATE INDEX "mumble_mumble_server_id" ON "mumble_mumble" ("server_id"); ALTER TABLE "mumble_mumble" DROP CONSTRAINT "mumble_mumble_addr_key"; +COMMIT; diff --git a/pyweb/mumble/conversionsql/pgsql/11-data-mumble_mumbleserver.sql b/pyweb/mumble/conversionsql/pgsql/11-data-mumble_mumbleserver.sql index f53f7eb..bf88107 100644 --- a/pyweb/mumble/conversionsql/pgsql/11-data-mumble_mumbleserver.sql +++ b/pyweb/mumble/conversionsql/pgsql/11-data-mumble_mumbleserver.sql @@ -1,3 +1,5 @@ +BEGIN; INSERT INTO "mumble_mumbleserver" ( "dbus", "secret" ) SELECT DISTINCT "dbus", '' FROM "mumble_mumble"; +COMMIT; diff --git a/pyweb/mumble/conversionsql/pgsql/12-data-mumble_mumble.sql b/pyweb/mumble/conversionsql/pgsql/12-data-mumble_mumble.sql index 04ed3b4..2d882db 100644 --- a/pyweb/mumble/conversionsql/pgsql/12-data-mumble_mumble.sql +++ b/pyweb/mumble/conversionsql/pgsql/12-data-mumble_mumble.sql @@ -1,6 +1,8 @@ +BEGIN; UPDATE "mumble_mumble" SET "server_id"=( SELECT "id" FROM "mumble_mumbleserver" WHERE "mumble_mumbleserver"."dbus" = "mumble_mumble"."dbus" ); +COMMIT; diff --git a/pyweb/mumble/conversionsql/pgsql/21-schema-cleanup-mumble.sql b/pyweb/mumble/conversionsql/pgsql/21-schema-cleanup-mumble.sql index e8d12ef..b6aad01 100644 --- a/pyweb/mumble/conversionsql/pgsql/21-schema-cleanup-mumble.sql +++ b/pyweb/mumble/conversionsql/pgsql/21-schema-cleanup-mumble.sql @@ -1,4 +1,5 @@ -- Model: Mumble +BEGIN; ALTER TABLE "mumble_mumble" DROP COLUMN "dbus"; ALTER TABLE "mumble_mumble" @@ -30,3 +31,4 @@ ALTER TABLE "mumble_mumble" ALTER TABLE "mumble_mumble" ALTER COLUMN "server_id" SET NOT NULL; +COMMIT; \ No newline at end of file diff --git a/pyweb/mumble/conversionsql/pgsql/22-schema-cleanup-mumbleuser.sql b/pyweb/mumble/conversionsql/pgsql/22-schema-cleanup-mumbleuser.sql index 26970f0..05b86c8 100644 --- a/pyweb/mumble/conversionsql/pgsql/22-schema-cleanup-mumbleuser.sql +++ b/pyweb/mumble/conversionsql/pgsql/22-schema-cleanup-mumbleuser.sql @@ -1,3 +1,5 @@ -- Model: MumbleUser +BEGIN; ALTER TABLE "mumble_mumbleuser" DROP COLUMN "isAdmin"; +COMMIT; diff --git a/pyweb/mumble/management/update_schema.py b/pyweb/mumble/management/update_schema.py index cbf2f82..934f8db 100644 --- a/pyweb/mumble/management/update_schema.py +++ b/pyweb/mumble/management/update_schema.py @@ -45,8 +45,6 @@ def update_schema( **kwargs ): try: stmt = scriptfile.read() cursor.execute( stmt ) - if "postgresql" in settings.DATABASE_ENGINE: - transaction.commit() except IOError, err: print "Error reading file '%s':" % filename @@ -55,8 +53,6 @@ def update_schema( **kwargs ): except cursor.db.connection.Error, err: print "Error executing file '%s':" % filename print err - if "postgresql" in settings.DATABASE_ENGINE: - transaction.rollback() finally: scriptfile.close()