mig wrapper to kmig/emig
authorJason Etheridge <jason@equinoxinitiative.org>
Fri, 10 Apr 2020 18:44:58 +0000 (14:44 -0400)
committerJason Etheridge <jason@equinoxinitiative.org>
Fri, 10 Apr 2020 18:44:58 +0000 (14:44 -0400)
It won't handle first time setup; you'll need to call emig or kmig explicitly
until an environment is loaded.

Example:

    kmig env create demo
    kmig env use demo
    mig init
    mig add foo.txt etc

Also, the older ~/.mig environment directory, if used with the new mig, will
need to be moved or merged into ~/.emig, and the various *.env files ammended
with:

    export MIGCMD=emig

emig.d/bin/mig-env
kmig.d/bin/mig-env
mig [new file with mode: 0755]

index 7ed2b71..5ee9971 100755 (executable)
@@ -242,6 +242,7 @@ sub mig_env_create {
     print FILE "export PGDATABASE=$PGDATABASE\n";
     print FILE "export PGUSER=$PGUSER\n";
     print FILE "export PGOPTIONS='-c search_path=$migration_schema,public,evergreen'\n";
+    print FILE "export MIGCMD=emig\n";
     print FILE "export MIGENVPROMPT=$migration_schema\n";
     print FILE "export MIGSCHEMA=$migration_schema\n";
     print FILE "export MIGBASEWORKDIR=$MIGBASEWORKDIR\n";
index 2ce6f32..0ef503b 100755 (executable)
@@ -272,6 +272,7 @@ sub mig_env_create {
     print FILE "export MYSQL_USER=$MYSQL_USER\n";
     #TODO - brittle; need to escape the password string
     print FILE "export MYSQL_PW=$MYSQL_PW\n";
+    print FILE "export MIGCMD=kmig\n";
     print FILE "export MIGENVPROMPT=$migration_schema\n";
     print FILE "export MIGSCHEMA=$migration_schema\n";
     print FILE "export MIGBASEWORKDIR=$MIGBASEWORKDIR\n";
diff --git a/mig b/mig
new file mode 100755 (executable)
index 0000000..ee680de
--- /dev/null
+++ b/mig
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+###############################################################################
+=pod
+
+=head1 NAME
+
+mig - git-like program for tracking and manipulating legacy data files for
+migrations.  This is a smart wrapper around emig and kmig (for Evergreen and
+Koha migrations, respectively).  It'll fail if the MIGCMD environment variable
+is not set.  Environments created through kmig env and emig env should set
+MIGCMD accordingly.
+
+=cut
+
+###############################################################################
+
+use strict;
+use Env qw(
+    MIGCMD
+);
+use Pod::Usage;
+
+pod2usage(-verbose => 2) if ! $ARGV[0];
+if ($MIGCMD) {
+    system($MIGCMD,@ARGV);
+} else {
+    die "Please use emig/kmig to load an environment.";
+}
+