Browse Source

sqlite: create a new table with the proper schema to get rid of the old fields.

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
072612d0b4
  1. 13
      pyweb/mumble/conversionsql/sqlite/01-schema-mumble-server_id.sql
  2. 2
      pyweb/mumble/conversionsql/sqlite/02-schema-mumble_mumbleuser.sql
  3. 17
      pyweb/mumble/conversionsql/sqlite/12-data-mumble_mumble.sql
  4. 1
      pyweb/mumble/conversionsql/sqlite/21-rename-old-table.sql
  5. 1
      pyweb/mumble/conversionsql/sqlite/22-rename-new-table.sql

13
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")
);

2
pyweb/mumble/conversionsql/sqlite/02-schema-mumble_mumbleuser.sql

@ -1,2 +0,0 @@
ALTER TABLE "mumble_mumble"
ADD "display" varchar(200);

17
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"

1
pyweb/mumble/conversionsql/sqlite/21-rename-old-table.sql

@ -0,0 +1 @@
ALTER TABLE "mumble_mumble" RENAME TO "mumble_mumble_old";

1
pyweb/mumble/conversionsql/sqlite/22-rename-new-table.sql

@ -0,0 +1 @@
ALTER TABLE "mumble_mumble_new" RENAME TO "mumble_mumble";
Loading…
Cancel
Save