- croak "Not running uid freeside!" unless checkeuid();
- getsecrets;
- $dbh->disconnect if $dbh;
- $dbh = DBI->connect($datasrc,$db_user,$db_pass, {
- 'AutoCommit' => 0,
- 'ChopBlanks' => 1,
- } ) or die "DBI->connect error: $DBI::errstr\n";
+}
+
+sub load_schema {
+ warn "$me loading schema\n" if $DEBUG;
+ getsecrets() unless $datasrc;
+ use FS::Schema qw(reload_dbdef dbdef);
+ reload_dbdef("$conf_dir/dbdef.$datasrc")
+ unless $FS::Schema::setup_hack;
+}
+
+sub db_setup {
+ croak "Not running uid freeside (\$>=$>, \$<=$<)\n" unless checkeuid();
+
+ warn "$me forksuidsetup connecting to database\n" if $DEBUG;
+ $dbh = &myconnect();
+
+ warn "$me forksuidsetup connected to database with handle $dbh\n" if $DEBUG;
+
+ load_schema();
+
+ warn "$me forksuidsetup deciding upon config system to use\n" if $DEBUG;
+
+ unless ( $FS::Schema::setup_hack ) {
+
+ #how necessary is this now that we're no longer possibly a pre-1.9 db?
+ my $sth = $dbh->prepare("SELECT COUNT(*) FROM conf") or die $dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ $sth->fetchrow_arrayref->[0] or die "NO CONFIGURATION RECORDS FOUND";