[freeside-commits] branch FREESIDE_4_BRANCH updated. aa225fb652d1917dd6af6c8fafaa5720f96ed394
Ivan
ivan at 420.am
Wed Jul 26 09:28:55 PDT 2017
The branch, FREESIDE_4_BRANCH has been updated
via aa225fb652d1917dd6af6c8fafaa5720f96ed394 (commit)
from d90496a1300edfaf9ad1369f05669cbd3970461b (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 aa225fb652d1917dd6af6c8fafaa5720f96ed394
Author: Ivan Kohler <ivan at freeside.biz>
Date: Wed Jul 26 09:28:54 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