freeside/bin sequences.reset,NONE,1.1
ivan
ivan at pouncequick.420.am
Wed May 12 11:02:22 PDT 2004
Update of /home/cvs/cvsroot/freeside/bin
In directory pouncequick:/tmp/cvs-serv30017
Added Files:
sequences.reset
Log Message:
adding
--- NEW FILE: sequences.reset ---
#!/usr/bin/perl
use FS::UID qw(adminsuidsetup);
use FS::Record qw(dbdef dbh);
my $user = shift;
adminsuidsetup $user or die;
foreach my $table ( dbdef->tables ) {
my $primary_key = dbdef->table($table)->primary_key;
next unless $primary_key;
#my $local = dbdef->table($table)->column($primary_key)->local;
##next unless $default =~ /nextval/;
#print "$local\n";
my $statement = "select setval('${table}_${primary_key}_seq', ( select max($primary_key) from $table ) )\n";
my $sth = dbh->prepare($statement) or do {
warn dbh->errstr. " preparing $statement\n";
next;
};
$sth->execute or do {
warn dbh->errstr. " executing $statement\n";
dbh->commit;
next;
}
}
More information about the freeside-commits
mailing list