[Rt-commit] rt branch, 4.0/set-articles-seq-nextval, created. rt-4.0.23-19-g465e1f7

Todd Wade todd at bestpractical.com
Thu Mar 26 21:31:38 EDT 2015


The branch, 4.0/set-articles-seq-nextval has been created
        at  465e1f7dd792ad7343d6d61b7c8c058893b1028f (commit)

- Log -----------------------------------------------------------------
commit 465e1f7dd792ad7343d6d61b7c8c058893b1028f
Author: Todd Wade <todd at bestpractical.com>
Date:   Thu Mar 26 21:29:06 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.

diff --git a/etc/upgrade/4.0.24/schema.Pg b/etc/upgrade/4.0.24/schema.Pg
new file mode 100644
index 0000000..7af25eb
--- /dev/null
+++ b/etc/upgrade/4.0.24/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 21cba4b..101e6b9 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -262,3 +262,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', COALESCE( MAX(id), 1) ) FROM Articles";
+        $RT::Logger->debug($sql);
+        $dbh->do($sql);
+    }
+}

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


More information about the rt-commit mailing list