#!/usr/bin/perl
use strict;
# Change the path below to the correct one for your site
use lib '/path/to/admin';
use Links qw/$CFG $IN $DB/;
# Again, change the path below to the correct one for your site
Links::init('/path/to/admin');
&main;
sub main {
print $IN->header;
if ( hastable('ESDaily')) {
print 'ESDaily table found.
';
my $editor1 = $DB->editor('ESDaily');
#Add indexes to ESDaily table to speed up searches
$editor1->add_index( Datendx => ['Date','LinkID'] ) or print "Unable to add index' ($GT::SQL::error)
";
print "ESDaily Table Updated.
";
}
if ( hastable('ESMonthly')) {
print 'ESMonthly table found.
';
my $editor2 = $DB->editor('ESMonthly');
$editor2->add_index( Datendx => ['Year','Month','LinkID'] ) or print "Unable to add index' ($GT::SQL::error)
";
print "ESMonthly Table Updated.
";
}
print "The tables have been successfully updated!";
}
sub hastable {
#---------------------------
# Determine if a table exists
# Return true if it does.
my $table = shift;
my $exists = 0;
my $def_path = "$CFG->{admin_root_path}/defs/" . $DB->prefix() . "$table.def";
if (-e $def_path) { $exists = 1; }
return $exists;
}
1;