Siegfried Gevatter has proposed merging lp:~zeitgeist/zeitgeist/dbschema4 into
lp:zeitgeist with lp:~zeitgeist/zeitgeist/storagemonitor2 as a prerequisite.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
This branch includes the two remaining schema changes. It should be merged at
the same time as the storage monitor so people will get all updates at once.
--
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
Your team Zeitgeist Framework Team is requested to review the proposed merge of
lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/main.py'
--- _zeitgeist/engine/main.py 2011-02-10 10:55:44 +
+++ _zeitgeist/engine/main.py 2011-03-04 22:36:33 +
@@ -613,7 +613,8 @@
for subject in event.subjects:
self._cursor.execute(
INSERT INTO event VALUES (
- ?, ?, ?, ?, ?, ?,
+ ?, ?, ?, ?, ?, ?, ?,
+ (SELECT id FROM uri WHERE value=?),
(SELECT id FROM uri WHERE value=?),
?, ?,
(SELECT id FROM uri WHERE value=?),
@@ -626,8 +627,10 @@
self._interpretation[event.interpretation],
self._manifestation[event.manifestation],
self._actor[event.actor],
+ None, # event origin
payload_id,
subject.uri,
+ subject.uri,
self._interpretation[subject.interpretation],
self._manifestation[subject.manifestation],
subject.origin,
=== modified file '_zeitgeist/engine/sql.py'
--- _zeitgeist/engine/sql.py 2011-03-04 22:36:33 +
+++ _zeitgeist/engine/sql.py 2011-03-04 22:36:33 +
@@ -260,10 +260,12 @@
id INTEGER,
timestamp INTEGER,
interpretation INTEGER,
- manifestation INTEGER,
- actor INTEGER,
+ manifestation INTEGER,
+ actor INTEGER,
+ origin INTEGER,
payload INTEGER,
subj_id INTEGER,
+ subj_id_current INTEGER,
subj_interpretation INTEGER,
subj_manifestation INTEGER,
subj_origin INTEGER,
@@ -276,10 +278,14 @@
REFERENCES manifestation(id) ON DELETE CASCADE,
CONSTRAINT actor_fk FOREIGN KEY(actor)
REFERENCES actor(id) ON DELETE CASCADE,
+ CONSTRAINT actor_fk FOREIGN KEY(origin)
+REFERENCES uri(id) ON DELETE CASCADE,
CONSTRAINT payload_fk FOREIGN KEY(payload)
REFERENCES payload(id) ON DELETE CASCADE,
CONSTRAINT subj_id_fk FOREIGN KEY(subj_id)
REFERENCES uri(id) ON DELETE CASCADE,
+ CONSTRAINT subj_id_current_fk FOREIGN KEY(subj_id_current)
+REFERENCES uri(id) ON DELETE CASCADE,
CONSTRAINT subj_interpretation_fk FOREIGN KEY(subj_interpretation)
REFERENCES interpretation(id) ON DELETE CASCADE,
CONSTRAINT subj_manifestation_fk FOREIGN KEY(subj_manifestation)
@@ -311,9 +317,15 @@
CREATE INDEX IF NOT EXISTS event_actor
ON event(actor))
cursor.execute(
+ CREATE INDEX IF NOT EXISTS event_origin
+ ON event(origin))
+ cursor.execute(
CREATE INDEX IF NOT EXISTS event_subj_id
ON event(subj_id))
cursor.execute(
+ CREATE INDEX IF NOT EXISTS event_subj_id_current
+ ON event(subj_id_current))
+ cursor.execute(
CREATE INDEX IF NOT EXISTS event_subj_interpretation
ON event(subj_interpretation))
cursor.execute(
@@ -353,24 +365,25 @@
% {'column': column, 'table': table})
# ... special cases
- cursor.execute(
- CREATE TRIGGER IF NOT EXISTS fkdc_event_uri_1
- BEFORE DELETE ON event
- WHEN ((SELECT COUNT(*) FROM event WHERE subj_id=OLD.subj_id OR subj_origin=OLD.subj_id) 2)
- BEGIN
- DELETE FROM uri WHERE id=OLD.subj_id;
- END;
- % {'column': column, 'table': table})
- cursor.execute(
- CREATE TRIGGER IF NOT EXISTS fkdc_event_uri_2
- BEFORE DELETE ON event
- WHEN ((SELECT COUNT(*) FROM event WHERE subj_id=OLD.subj_origin OR subj_origin=OLD.subj_origin) 2)
- BEGIN
- DELETE FROM uri WHERE id=OLD.subj_origin;
- END;
- % {'column': column, 'table': table})
+ for num, column in enumerate(('subj_id', 'subj_origin',
+ 'subj_id_current', 'origin')):
+ cursor.execute(
+ CREATE TRIGGER IF NOT EXISTS fkdc_event_uri_%(num)d
+ BEFORE DELETE ON event
+ WHEN ((
+SELECT COUNT(*)
+FROM event
+WHERE
+ origin=OLD.%(column)s
+ OR subj_id=OLD.%(column)s
+ OR subj_id_current=OLD.%(column)s
+ OR subj_origin=OLD.%(column)s
+) 2)
+ BEGIN
+DELETE FROM uri WHERE id=OLD.%(column)s;
+ END;
+ % {'num': num+1, 'column': column})
- # TODO: Make the DROP conditional to version upgrades. How?
cursor.execute(DROP VIEW IF EXISTS event_view)
cursor.execute(
CREATE VIEW IF NOT EXISTS event_view AS
=== modified file '_zeitgeist/engine/upgrades/core_3_4.py'
--- _zeitgeist/engine/upgrades/core_3_4.py 2011-03-04 22:36:33 +
+++ _zeitgeist/engine/upgrades/core_3_4.py 2011-03-04 22:36:33 +
@@ -22,6 +22,80 @@
# That way they will always be marked as available. We don't have a chance
# of properly backtracking all items, so we use this as a clutch
cursor.execute(UPDATE