summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-12-05 18:51:14 +0100
committerYorhel <git@yorhel.nl>2009-12-05 18:56:46 +0100
commit6daab15dc03a82ac6f782edbe4c509e2fedf5746 (patch)
treeb80cb360c4372a80abc4dcb09c3c296f2481c610 /util
parent9aa6f31f9a800157dd6899e3b237316890e2872f (diff)
SQL: Removed changes.causedby
This column was used to differentiate between automated edits and user edits, but that later changed to checking for changes.requester = 1. The column has since never really been used, and due to a bug introduced in VNDB 2.0, it has never been updated, either. Meaning it's not even accurate for any database changes made after december 2008...
Diffstat (limited to 'util')
-rw-r--r--util/dump.sql4
-rw-r--r--util/updates/update_2.10.sql11
2 files changed, 12 insertions, 3 deletions
diff --git a/util/dump.sql b/util/dump.sql
index 2e2b6cf7..66db690c 100644
--- a/util/dump.sql
+++ b/util/dump.sql
@@ -38,8 +38,7 @@ CREATE TABLE changes (
added timestamptz NOT NULL DEFAULT NOW(),
requester integer NOT NULL DEFAULT 0,
ip inet NOT NULL DEFAULT '0.0.0.0',
- comments text NOT NULL DEFAULT '',
- causedby integer
+ comments text NOT NULL DEFAULT ''
);
-- producers
@@ -365,7 +364,6 @@ CREATE TABLE wlists (
ALTER TABLE changes ADD FOREIGN KEY (requester) REFERENCES users (id);
-ALTER TABLE changes ADD FOREIGN KEY (causedby) REFERENCES changes (id);
ALTER TABLE producers ADD FOREIGN KEY (latest) REFERENCES producers_rev (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE producers ADD FOREIGN KEY (rgraph) REFERENCES relgraphs (id);
ALTER TABLE producers_relations ADD FOREIGN KEY (pid1) REFERENCES producers_rev (id);
diff --git a/util/updates/update_2.10.sql b/util/updates/update_2.10.sql
index e034b6e8..ad2dd1c7 100644
--- a/util/updates/update_2.10.sql
+++ b/util/updates/update_2.10.sql
@@ -182,3 +182,14 @@ $$ LANGUAGE plpgsql;
CREATE TRIGGER release_vncache_update AFTER UPDATE ON releases FOR EACH ROW EXECUTE PROCEDURE release_vncache_update();
+-- remove changes.causedby and give the affected changes to Multi
+UPDATE changes SET requester = 1 WHERE causedby IS NOT NULL;
+ALTER TABLE changes DROP COLUMN causedby;
+UPDATE users SET
+ c_changes = COALESCE((
+ SELECT COUNT(id)
+ FROM changes
+ WHERE requester = users.id
+ GROUP BY requester
+ ), 0);
+