[evolvis-commits] r6948: *EXPERIMENTAL* *DANGEROUS* *UNTESTED* DATABASE CHANGE↵ ↵ Retire artifact_artifact_id_seq and project_task_pk_seq SEQUENCEs↵ in favour of a new tasktracker_seq SEQUENCE which provides unique↵ IDs to both Task and Tracker items , from now on. ↵
mirabilos at evolvis.org
mirabilos at evolvis.org
Tue Sep 7 19:05:14 CEST 2010
Author: mirabilos
Date: 2010-09-07 19:05:14 +0200 (Tue, 07 Sep 2010)
New Revision: 6948
Modified:
trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTask.class.php
trunk/gforge_base/evolvisforge/gforge/deb-specific/db-upgrade.pl
trunk/gforge_base/evolvisforge/gforge/debian/changelog
trunk/gforge_base/evolvisforge/tools/bugzilla2GForge.pl
Log:
*EXPERIMENTAL* *DANGEROUS* *UNTESTED* DATABASE CHANGE
Retire artifact_artifact_id_seq and project_task_pk_seq SEQUENCEs
in favour of a new tasktracker_seq SEQUENCE which provides unique
IDs to both Task and Tracker items, from now on.
Modified: trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTask.class.php
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTask.class.php 2010-09-07 17:05:12 UTC (rev 6947)
+++ trunk/gforge_base/evolvisforge/gforge/common/pm/ProjectTask.class.php 2010-09-07 17:05:14 UTC (rev 6948)
@@ -195,7 +195,7 @@
} else {
$res = db_query_params ('SELECT nextval($1) AS id',
- array ('project_task_pk_seq'));
+ array ('tasktracker_seq'));
if (!$project_task_id=db_result($res,0,'id')) {
$this->setError( 'Could Not Get Next Project Task ID' );
db_rollback();
Modified: trunk/gforge_base/evolvisforge/gforge/deb-specific/db-upgrade.pl
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/deb-specific/db-upgrade.pl 2010-09-07 17:05:12 UTC (rev 6947)
+++ trunk/gforge_base/evolvisforge/gforge/deb-specific/db-upgrade.pl 2010-09-07 17:05:14 UTC (rev 6948)
@@ -3153,6 +3153,55 @@
$dbh->commit () ;
}
+ $version = &get_db_version ;
+ $target = "4.8.3+evolvis24.2" ;
+ if (&is_lesser ($version, $target)) {
+ &debug ("Tracker/Tasks unique ID sequence") ;
+ @reqlist = (
+ # "sanitise" sequences (example from init-sequences.sql)
+ "SELECT setval('artifact_artifact_id_seq',
+ (SELECT max(artifact_id)+1 FROM artifact));",
+ "SELECT setval('project_task_pk_seq',
+ (SELECT max(project_task_id)+1 FROM project_task));",
+ # dynamically create tasktracker_seq as bigger of the two
+ q{
+ CREATE FUNCTION tasktracker_seq_creator(v bigint) RETURNS void AS $$
+ BEGIN
+ EXECUTE 'CREATE SEQUENCE tasktracker_seq MINVALUE ' || v || ' NO MAXVALUE NO CYCLE;';
+ END;
+ $$ LANGUAGE plpgsql;
+ },
+ "SELECT tasktracker_seq_creator(GREATEST(
+ nextval('artifact_artifact_id_seq'),
+ nextval('project_task_pk_seq')
+ ))",
+ "DROP FUNCTION tasktracker_seq_creator(bigint);",
+ # switch artifact and project_task tables to tasktracker_seq
+ "ALTER TABLE artifact
+ ALTER COLUMN artifact_id
+ SET DEFAULT nextval(('tasktracker_seq'::text)::regclass)",
+ "ALTER TABLE project_task
+ ALTER COLUMN project_task_id
+ SET DEFAULT nextval(('tasktracker_seq'::text)::regclass)",
+ # and remove the old sequences from the DB
+ "DROP SEQUENCE artifact_artifact_id_seq",
+ "DROP SEQUENCE project_task_pk_seq",
+ ) ;
+
+ foreach my $s (@reqlist) {
+ $query = $s ;
+ # debug $query ;
+ $sth = $dbh->prepare ($query) ;
+ $sth->execute () ;
+ $sth->finish () ;
+ }
+ @reqlist = () ;
+
+ &update_db_version ($target) ;
+ &debug ("Committing.") ;
+ $dbh->commit () ;
+ }
+
########################### INSERT HERE #################################
&debug ("It seems your database $action went well and smoothly. That's cool.") ;
Modified: trunk/gforge_base/evolvisforge/gforge/debian/changelog
===================================================================
--- trunk/gforge_base/evolvisforge/gforge/debian/changelog 2010-09-07 17:05:12 UTC (rev 6947)
+++ trunk/gforge_base/evolvisforge/gforge/debian/changelog 2010-09-07 17:05:14 UTC (rev 6948)
@@ -35,6 +35,11 @@
* In Tasks and Tracker Browse, make the ID into a href for the
permalink, for ease of grepping
* Allow hyperlinks (via grabbing) in Tracker and Task comments
+ * Use one SQL SEQUENCE for both Tasks and Tracker to make IDs
+ of those items (if created after the change) unique so that
+ #1234 refers to either a task item or a tracker item, but
+ not both; use SELECT min_value FROM tasktracker_seq to find
+ which value is the lowest for that this assumption can hold
[ Lukas Degener ]
* Make the SOAP WSDL compile
@@ -42,7 +47,7 @@
[ Alain Peyrat ]
* Switch default search type from OR to AND
- -- Thorsten Glaser <t.glaser at tarent.de> Tue, 07 Sep 2010 17:46:35 +0200
+ -- Thorsten Glaser <t.glaser at tarent.de> Tue, 07 Sep 2010 18:59:52 +0200
gforge (4.8.3+evolvis24) unstable; urgency=low
Modified: trunk/gforge_base/evolvisforge/tools/bugzilla2GForge.pl
===================================================================
--- trunk/gforge_base/evolvisforge/tools/bugzilla2GForge.pl 2010-09-07 17:05:12 UTC (rev 6947)
+++ trunk/gforge_base/evolvisforge/tools/bugzilla2GForge.pl 2010-09-07 17:05:14 UTC (rev 6948)
@@ -1,4 +1,9 @@
#!/usr/bin/perl -w
+
+# this will not work, since we use the same SEQUENCE for
+# tracker and tasks in Evolvis
+die "broken";
+
# bugzilla2gforge.pl - transfers bug reports from Bugzilla to gforge.
# steev hise, steev AT datamassage.com, december 2001
# todd wallentine, tcw AT ksu edu, february 2002
More information about the evolvis-commits
mailing list