[Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist

2011-04-05 Thread noreply
The proposal to merge lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist has 
been updated.

Status: Needs review = Merged

For more details, see:
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
Your team Zeitgeist Framework Team is subscribed to branch 
lp:~zeitgeist/zeitgeist/storagemonitor2.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


Re: [Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist

2011-03-14 Thread Mikkel Kamstrup Erlandsen
Review: Approve
Awesome Siegfried :-)

Code looks good to me and the tests all run. I think we may want to make a 
backup copy in the upgrade script - before we do anything. This is by far the 
most complex upgrade we have.

Does that mean 0.7 is compatible with the amendment you made to the INSERT? In 
that case I think it could make sense with a 0.7 point release when we roll 0.8.
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
Your team Zeitgeist Framework Team is subscribed to branch 
lp:~zeitgeist/zeitgeist/storagemonitor2.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


Re: [Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist

2011-03-12 Thread Siegfried Gevatter
OK, so I've moved the new columns to the end of the table and now Zeitgeist 0.7 
is at least able to read an upgraded database. Unfortunately it looks like we 
won't get around breaking compatibility for inserts, since:
  OperationalError: table event has 15 columns but 13 values were supplied

I've changed the INSERT statement to list all columns explicitly so if we ever 
need to change the table in the future this won't happen again.
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
Your team Zeitgeist Framework Team is subscribed to branch 
lp:~zeitgeist/zeitgeist/storagemonitor2.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


Re: [Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist

2011-03-07 Thread Siegfried Gevatter
Indeed, thanks for catching that.

There's one additional issue, as discussed on IRC:
19:07 RainCT seiflotfy: should ZG 0.7 and 0.8 be compatible?
19:08 seiflotfy RainCT, how so ur asing
19:09 RainCT ZG isn't specifying the column names when it creates an event
19:09 RainCT so if you update to 0.8 and run 0.7 it will put stuff in the 
wrong columns
19:11 RainCT I think a workaround would be adding the new columns to the end 
of the table (which sucks since the table will look ugly :P) and then having a 
triger which looks for inserts into events
19:11 RainCT and if subj_id_current is empty sets it to the same value as 
subj_id
19:26 mhr3 making the db non-backwards compatible would probably be better
19:26 mhr3 of course do a backup before converting it first
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
Your team Zeitgeist Framework Team is subscribed to branch 
lp:~zeitgeist/zeitgeist/storagemonitor2.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


Re: [Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist

2011-03-05 Thread Mikkel Kamstrup Erlandsen
Review: Needs Fixing
I haven't properly reviewed this yet - but this caught my eye:

48  + CONSTRAINT actor_fk FOREIGN KEY(origin)
49  + REFERENCES uri(id) ON DELETE CASCADE,

I think it should be CONSTRAINT origin_fk instead, right?
-- 
https://code.launchpad.net/~zeitgeist/zeitgeist/dbschema4/+merge/52265
Your team Zeitgeist Framework Team is subscribed to branch 
lp:~zeitgeist/zeitgeist/storagemonitor2.

___
Mailing list: https://launchpad.net/~zeitgeist
Post to : zeitgeist@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zeitgeist
More help   : https://help.launchpad.net/ListHelp


[Zeitgeist] [Merge] lp:~zeitgeist/zeitgeist/dbschema4 into lp:zeitgeist

2011-03-04 Thread Siegfried Gevatter
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