use FindBin;
my $mig_bin = "$FindBin::Bin/";
use lib "$FindBin::Bin/";
-use Mig;
+use EMig;
pod2usage(-verbose => 2) if ! $ARGV[0] || $ARGV[0] eq '--help';
-Mig::die_if_no_env_migschema();
-Mig::die_if_mig_tracking_table_does_not_exist();
+EMig::die_if_no_env_migschema();
+EMig::die_if_mig_tracking_table_does_not_exist();
my $column_filter = 1; # show all fields
my $file = abs_path($ARGV[0]);
my $fdata;
-my $tracked_file_id = Mig::check_for_tracked_file($file);
+my $tracked_file_id = EMig::check_for_tracked_file($file);
if ($tracked_file_id) {
- $fdata = Mig::status_this_file($file);
+ $fdata = EMig::status_this_file($file);
} else {
die "File not currently tracked: $file\n";
}
printf "%-30s", "---------";
printf "%-30s", "--------------";
print "\n";
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $sth = $dbh->prepare("
SELECT *
FROM information_schema.columns
print "\n";
$sth->finish;
$sth2->finish;
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
}
sub column_menu {
my $dtd_identifier = shift;
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $sth = $dbh->prepare("
SELECT *
FROM information_schema.columns
|| die "Error retrieving data from information_schema: $!";
my $data = $sth->fetchrow_hashref;
$sth->finish;
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
my $column = $data->{column_name};
sub list_ten {
my $column = shift;
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $sth;
my $rv;
my @cols;
- $sth = $dbh->prepare(Mig::sql("
+ $sth = $dbh->prepare(EMig::sql("
SELECT " . (defined $column ? $column : '*') . "
FROM $MIGSCHEMA.$table
LIMIT 10;
my $min_value_as_timestamptz;
my $max_value_as_timestamptz;
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $sth;
my $rv;
my @cols;
$sth->finish;
$max_value_as_timestamptz = $cols[0];
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
print "\n";
print "# of rows = $count\n";
sub group_browse {
my ($column,$option) = (shift,shift||"GROUP BY 1 ORDER BY 1");
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $sth;
my $rv;
- $sth = $dbh->prepare(Mig::sql("
+ $sth = $dbh->prepare(EMig::sql("
SELECT $column, COUNT(*)
FROM $MIGSCHEMA.$table
$option;
sub add_this_column {
my $column = shift;
- if (!Mig::check_for_tracked_column($table,$column)) {
- my $dbh = Mig::db_connect();
+ if (!EMig::check_for_tracked_column($table,$column)) {
+ my $dbh = EMig::db_connect();
my $rv = $dbh->do("
INSERT INTO $MIGSCHEMA.tracked_column (
base_filename
," . $dbh->quote($column) . "
);
") || die "Error inserting into table $MIGSCHEMA.tracked_column: $!\n";
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
}
}
sub status_this_column {
my $column = shift;
- my $data = Mig::status_this_column($table,$column);
+ my $data = EMig::status_this_column($table,$column);
if (!$data) {
add_this_column($column);
- $data = Mig::status_this_column($table,$column);
+ $data = EMig::status_this_column($table,$column);
}
if ($$data{parent_table}) {
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $sth = $dbh->prepare("
SELECT *
FROM $MIGSCHEMA.fields_requiring_mapping
$$data{required} = 0;
}
$sth->finish;
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
}
return $data;
}
my ($column,$comment) = (shift,shift);
if ($comment) {
my $data = status_this_column($column);
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $rv = $dbh->do("
UPDATE $MIGSCHEMA.tracked_column
SET comment = " . $dbh->quote($comment) . "
WHERE id = " . $dbh->quote($data->{id}) . ";
") || die "Error updating table $MIGSCHEMA.tracked_column: $!\n";
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
}
}
my ($column,$transform) = (shift,shift);
if ($transform) {
my $data = status_this_column($column);
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $rv = $dbh->do("
UPDATE $MIGSCHEMA.tracked_column
SET transform = " . $dbh->quote($transform) . "
WHERE id = " . $dbh->quote($data->{id}) . ";
") || die "Error updating table $MIGSCHEMA.tracked_column: $!\n";
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
}
}
$target_column = $2;
}
my $data = status_this_column($column);
- my $dbh = Mig::db_connect();
+ my $dbh = EMig::db_connect();
my $rv = $dbh->do("
UPDATE $MIGSCHEMA.tracked_column
SET target_table = " . $dbh->quote($target_table) . "
,target_column = " . $dbh->quote($target_column) . "
WHERE id = " . $dbh->quote($data->{id}) . ";
") || die "Error updating table $MIGSCHEMA.tracked_column: $!\n";
- Mig::db_disconnect($dbh);
+ EMig::db_disconnect($dbh);
}
}