[Rt-commit] rt branch, 4.2/set-articles-seq-nextval, created. rt-4.2.10-223-g12a480c

Todd Wade todd at bestpractical.com
Thu Mar 26 21:51:19 EDT 2015


The branch, 4.2/set-articles-seq-nextval has been created
        at  12a480c2b3c0c3af9d39a1350750c8be84975daf (commit)

- Log -----------------------------------------------------------------
commit 12a480c2b3c0c3af9d39a1350750c8be84975daf
Author: Todd Wade <todd at bestpractical.com>
Date:   Thu Mar 26 21:44:02 2015 -0400

    properly migrate PostgreSQL Articles sequence objects
    https://issues.bestpractical.com/Ticket/Display.html?id=18248
    
    Set the articles sequence value to the max article id so that RT doesn't try
    to give new articles an id of 1 after upgrading.
    
    *NOTE* Oracle sequences haven't been tested and may need similar handling

diff --git a/etc/upgrade/4.2.11/schema.Pg b/etc/upgrade/4.2.11/schema.Pg
new file mode 100644
index 0000000..7af25eb
--- /dev/null
+++ b/etc/upgrade/4.2.11/schema.Pg
@@ -0,0 +1 @@
+SELECT SETVAL('articles_id_seq', COALESCE( MAX(id), 1) ) FROM Articles;
diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 742fd17..67d3e5e 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -259,3 +259,11 @@ sub copy_tables {
         warn "Updating Attribute ".$a->Name." to point to RT::Class";
     }
 }
+
+{ # update Postgres sequence
+    if ( $db_type eq 'Pg' ) {
+        my $sql = "SELECT SETVAL('articles_id_seq', MAX(id) ) FROM articles";
+        $RT::Logger->debug($sql);
+        $dbh->do($sql);
+    }
+}

-----------------------------------------------------------------------


More information about the rt-commit mailing list