[freeside-commits] branch master updated. eb191b6420d2a77218bdbfece57b92fdcfb5fa33

Ivan ivan at 420.am
Wed Jul 26 09:28:53 PDT 2017


The branch, master has been updated
       via  eb191b6420d2a77218bdbfece57b92fdcfb5fa33 (commit)
      from  c2e0d0fcb917af1832dd6eb1d1dd787b492eb387 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit eb191b6420d2a77218bdbfece57b92fdcfb5fa33
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jul 26 09:28:52 2017 -0700

    update fix-sequences for current DB

diff --git a/bin/fix-sequences b/bin/fix-sequences
index dc4abd7..896f01c 100755
--- a/bin/fix-sequences
+++ b/bin/fix-sequences
@@ -3,12 +3,6 @@
 # run dbdef-create first!
 
 use strict;
-use DBI;
-use DBIx::DBSchema 0.26;
-use DBIx::DBSchema::Table;
-use DBIx::DBSchema::Column;
-use DBIx::DBSchema::ColGroup::Unique;
-use DBIx::DBSchema::ColGroup::Index;
 use FS::UID qw(adminsuidsetup driver_name);
 use FS::Record qw(dbdef);
 
@@ -20,8 +14,10 @@ my $schema = dbdef();
 #false laziness w/fs-setup
 my @tables = scalar(@ARGV)
                ? @ARGV
-               : grep { ! /^h_/ } $schema->tables;
+               #: grep { ! /^h_/ } $schema->tables;
+               : $schema->tables;
 foreach my $table ( @tables ) {
+
   my $tableobj = $schema->table($table)
     or die "unknown table $table (did you run dbdef-create?)\n";
 
@@ -30,21 +26,30 @@ foreach my $table ( @tables ) {
 
   my $col = $tableobj->column($primary_key);
 
+#warn $col->type;
+my $default = ref($col->default) ? ${ $col->default } : $col->default;
+#use Data::Dumper;
+#warn Dumper $col;
 
   next unless uc($col->type) eq 'SERIAL'
               || ( driver_name eq 'Pg'
-                     && defined($col->default)
-                     && $col->default =~ /^nextval\(/i
+                     && defined($default)
+                     && $default =~ /^nextval\(/i
                  )
               || ( driver_name eq 'mysql'
                      && defined($col->local)
                      && $col->local =~ /AUTO_INCREMENT/i
                  );
 
-  my $seq = "${table}_${primary_key}_seq";
+  my $suffix = '_seq';
+  if ( $table =~ /^(objectcustomfields|objectcustomfieldvalues)$/ ) {
+    $suffix = '_s';
+  }
+
+  my $seq = "${table}_${primary_key}$suffix";
   if ( driver_name eq 'Pg'
-       && defined($col->default) 
-       && $col->default =~ /^nextval\('"(public\.)?(\w+_seq)"'::text\)$/
+       && defined($default) 
+       && $default =~ /^nextval\('"(public\.)?(\w+_seq)"'::(text|regclass)\)$/
      ) {
     $seq = $2;
   }

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

Summary of changes:
 bin/fix-sequences |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list