}
+# verify_tables()
+#
+# verify table existence
+#
+# parameter:
+# - class name ($self)
+# return:
+# - 0/1 (1 = OK)
+sub verify_tables {
+ my $self = shift;
+
+ my $query = "SELECT COUNT(1) AS count
+ FROM information_schema.tables
+ WHERE table_name IN ('docbot_key', 'docbot_url', 'docbot_user')";
+
+ my $st = $main::db->query($query);
+ if (!defined($st)) {
+ main::print_msg("Can't execute query - $DBI::errstr\n", ERROR);
+ return 0;
+ }
+
+ my @row = $st->fetchrow_array;
+ if ($row[0] != 3) {
+ main::print_msg("Missing one or more tables", ERROR);
+ return 0;
+ }
+
+ return 1;
+}
+
+
# ping()
#
# execute a test query
if (!$main::db->test_database()) {
die("Could not test database connection!\n");
}
+ # and verify table existence
+ if (!$main::db->verify_tables()) {
+ die("Required tables are not available!\n");
+ }
}