From 072612d0b442d9de01767c376180a1f00ce29050 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Sun, 21 Feb 2010 16:41:24 +0100 Subject: [PATCH] sqlite: create a new table with the proper schema to get rid of the old fields. --- .../sqlite/01-schema-mumble-server_id.sql | 13 +++++++++++-- .../sqlite/02-schema-mumble_mumbleuser.sql | 2 -- .../sqlite/12-data-mumble_mumble.sql | 17 +++++++++++------ .../sqlite/21-rename-old-table.sql | 1 + .../sqlite/22-rename-new-table.sql | 1 + 5 files changed, 24 insertions(+), 10 deletions(-) delete mode 100644 pyweb/mumble/conversionsql/sqlite/02-schema-mumble_mumbleuser.sql create mode 100644 pyweb/mumble/conversionsql/sqlite/21-rename-old-table.sql create mode 100644 pyweb/mumble/conversionsql/sqlite/22-rename-new-table.sql diff --git a/pyweb/mumble/conversionsql/sqlite/01-schema-mumble-server_id.sql b/pyweb/mumble/conversionsql/sqlite/01-schema-mumble-server_id.sql index 5785218..83faf0d 100644 --- a/pyweb/mumble/conversionsql/sqlite/01-schema-mumble-server_id.sql +++ b/pyweb/mumble/conversionsql/sqlite/01-schema-mumble-server_id.sql @@ -1,2 +1,11 @@ -ALTER TABLE "mumble_mumble" - ADD "server_id" integer; +CREATE TABLE "mumble_mumble_new" ( + "id" integer NOT NULL PRIMARY KEY, + "server_id" integer NOT NULL REFERENCES "mumble_mumbleserver" ("id"), + "name" varchar(200) NOT NULL, + "srvid" integer NOT NULL, + "addr" varchar(200) NOT NULL, + "port" integer NOT NULL, + "display" varchar(200) NOT NULL, + UNIQUE ("server_id", "srvid"), + UNIQUE ("addr", "port") +); diff --git a/pyweb/mumble/conversionsql/sqlite/02-schema-mumble_mumbleuser.sql b/pyweb/mumble/conversionsql/sqlite/02-schema-mumble_mumbleuser.sql deleted file mode 100644 index bc902fd..0000000 --- a/pyweb/mumble/conversionsql/sqlite/02-schema-mumble_mumbleuser.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "mumble_mumble" - ADD "display" varchar(200); diff --git a/pyweb/mumble/conversionsql/sqlite/12-data-mumble_mumble.sql b/pyweb/mumble/conversionsql/sqlite/12-data-mumble_mumble.sql index 04ed3b4..b7ca79b 100644 --- a/pyweb/mumble/conversionsql/sqlite/12-data-mumble_mumble.sql +++ b/pyweb/mumble/conversionsql/sqlite/12-data-mumble_mumble.sql @@ -1,6 +1,11 @@ -UPDATE "mumble_mumble" -SET "server_id"=( - SELECT "id" - FROM "mumble_mumbleserver" - WHERE "mumble_mumbleserver"."dbus" = "mumble_mumble"."dbus" - ); +INSERT INTO "mumble_mumble_new" +SELECT + "mumble_mumble"."id", + "mumble_mumbleserver"."id", + "mumble_mumble"."name", + "mumble_mumble"."srvid", + "mumble_mumble"."addr", + "mumble_mumble"."port", + '' +FROM "mumble_mumble" INNER JOIN "mumble_mumbleserver" +WHERE "mumble_mumbleserver"."dbus" = "mumble_mumble"."dbus" diff --git a/pyweb/mumble/conversionsql/sqlite/21-rename-old-table.sql b/pyweb/mumble/conversionsql/sqlite/21-rename-old-table.sql new file mode 100644 index 0000000..75775db --- /dev/null +++ b/pyweb/mumble/conversionsql/sqlite/21-rename-old-table.sql @@ -0,0 +1 @@ +ALTER TABLE "mumble_mumble" RENAME TO "mumble_mumble_old"; diff --git a/pyweb/mumble/conversionsql/sqlite/22-rename-new-table.sql b/pyweb/mumble/conversionsql/sqlite/22-rename-new-table.sql new file mode 100644 index 0000000..73921fb --- /dev/null +++ b/pyweb/mumble/conversionsql/sqlite/22-rename-new-table.sql @@ -0,0 +1 @@ +ALTER TABLE "mumble_mumble_new" RENAME TO "mumble_mumble";