Browse Source

move transaction handling from update_schema to the SQL scripts, as it didn't work.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
bced1f456d
  1. 1
      pyweb/mumble/admin.py
  2. 2
      pyweb/mumble/conversionsql/pgsql/01-schema-prepare-mumble.sql
  3. 2
      pyweb/mumble/conversionsql/pgsql/11-data-mumble_mumbleserver.sql
  4. 2
      pyweb/mumble/conversionsql/pgsql/12-data-mumble_mumble.sql
  5. 2
      pyweb/mumble/conversionsql/pgsql/21-schema-cleanup-mumble.sql
  6. 2
      pyweb/mumble/conversionsql/pgsql/22-schema-cleanup-mumbleuser.sql
  7. 4
      pyweb/mumble/management/update_schema.py

1
pyweb/mumble/admin.py

@ -54,6 +54,7 @@ class MumbleAdmin(admin.ModelAdmin):
def get_addr( self, obj ): def get_addr( self, obj ):
if not obj.addr: if not obj.addr:
return "*" return "*"
return obj.addr
get_addr.short_description = _('Server Address') get_addr.short_description = _('Server Address')

2
pyweb/mumble/conversionsql/pgsql/01-schema-prepare-mumble.sql

@ -1,4 +1,5 @@
-- Model: Mumble -- Model: Mumble
BEGIN;
ALTER TABLE "mumble_mumble" ALTER TABLE "mumble_mumble"
ADD "server_id" integer NULL REFERENCES "mumble_mumbleserver" ("id") DEFERRABLE INITIALLY DEFERRED; ADD "server_id" integer NULL REFERENCES "mumble_mumbleserver" ("id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "mumble_mumble" ALTER TABLE "mumble_mumble"
@ -9,3 +10,4 @@ ALTER TABLE "mumble_mumble"
CREATE INDEX "mumble_mumble_server_id" ON "mumble_mumble" ("server_id"); CREATE INDEX "mumble_mumble_server_id" ON "mumble_mumble" ("server_id");
ALTER TABLE "mumble_mumble" DROP CONSTRAINT "mumble_mumble_addr_key"; ALTER TABLE "mumble_mumble" DROP CONSTRAINT "mumble_mumble_addr_key";
COMMIT;

2
pyweb/mumble/conversionsql/pgsql/11-data-mumble_mumbleserver.sql

@ -1,3 +1,5 @@
BEGIN;
INSERT INTO "mumble_mumbleserver" ( "dbus", "secret" ) INSERT INTO "mumble_mumbleserver" ( "dbus", "secret" )
SELECT DISTINCT "dbus", '' SELECT DISTINCT "dbus", ''
FROM "mumble_mumble"; FROM "mumble_mumble";
COMMIT;

2
pyweb/mumble/conversionsql/pgsql/12-data-mumble_mumble.sql

@ -1,6 +1,8 @@
BEGIN;
UPDATE "mumble_mumble" UPDATE "mumble_mumble"
SET "server_id"=( SET "server_id"=(
SELECT "id" SELECT "id"
FROM "mumble_mumbleserver" FROM "mumble_mumbleserver"
WHERE "mumble_mumbleserver"."dbus" = "mumble_mumble"."dbus" WHERE "mumble_mumbleserver"."dbus" = "mumble_mumble"."dbus"
); );
COMMIT;

2
pyweb/mumble/conversionsql/pgsql/21-schema-cleanup-mumble.sql

@ -1,4 +1,5 @@
-- Model: Mumble -- Model: Mumble
BEGIN;
ALTER TABLE "mumble_mumble" ALTER TABLE "mumble_mumble"
DROP COLUMN "dbus"; DROP COLUMN "dbus";
ALTER TABLE "mumble_mumble" ALTER TABLE "mumble_mumble"
@ -30,3 +31,4 @@ ALTER TABLE "mumble_mumble"
ALTER TABLE "mumble_mumble" ALTER TABLE "mumble_mumble"
ALTER COLUMN "server_id" SET NOT NULL; ALTER COLUMN "server_id" SET NOT NULL;
COMMIT;

2
pyweb/mumble/conversionsql/pgsql/22-schema-cleanup-mumbleuser.sql

@ -1,3 +1,5 @@
-- Model: MumbleUser -- Model: MumbleUser
BEGIN;
ALTER TABLE "mumble_mumbleuser" ALTER TABLE "mumble_mumbleuser"
DROP COLUMN "isAdmin"; DROP COLUMN "isAdmin";
COMMIT;

4
pyweb/mumble/management/update_schema.py

@ -45,8 +45,6 @@ def update_schema( **kwargs ):
try: try:
stmt = scriptfile.read() stmt = scriptfile.read()
cursor.execute( stmt ) cursor.execute( stmt )
if "postgresql" in settings.DATABASE_ENGINE:
transaction.commit()
except IOError, err: except IOError, err:
print "Error reading file '%s':" % filename print "Error reading file '%s':" % filename
@ -55,8 +53,6 @@ def update_schema( **kwargs ):
except cursor.db.connection.Error, err: except cursor.db.connection.Error, err:
print "Error executing file '%s':" % filename print "Error executing file '%s':" % filename
print err print err
if "postgresql" in settings.DATABASE_ENGINE:
transaction.rollback()
finally: finally:
scriptfile.close() scriptfile.close()

Loading…
Cancel
Save