remove the migration-tools expectation for kmig
authorJason Etheridge <jason@equinoxinitiative.org>
Fri, 10 Apr 2020 16:06:29 +0000 (12:06 -0400)
committerJason Etheridge <jason@equinoxinitiative.org>
Fri, 10 Apr 2020 16:06:29 +0000 (12:06 -0400)
kmig.d/bin/KMig.pm
kmig.d/bin/kmig-init
kmig.d/sql/init/001-koha-staging-tables.sql [new file with mode: 0644]

index 45dd172..82b7f1b 100644 (file)
@@ -89,32 +89,6 @@ sub check_db_migschema_for_specific_table {
     return $found;
 }
 
-sub check_for_migration_tools {
-    my $dbh = db_connect();
-    my $sth = $dbh->prepare("
-        SELECT EXISTS(
-            SELECT 1
-            FROM information_schema.tables
-            WHERE table_schema = " . $dbh->quote( $MYSQL_DATABASE ) . "
-            AND table_name = " . $dbh->quote( 'mt_init' ) . "
-        );"
-    );
-    my $rv = $sth->execute()
-        || die "Error checking for migration_tools: $!";
-    my @cols = $sth->fetchrow_array;
-    $sth->finish;
-    db_disconnect($dbh);
-    return $cols[0];
-}
-
-sub die_if_no_migration_tools {
-    if (check_for_migration_tools()) {
-        print "Found migration_tools\n";
-    } else {
-        die "Missing migration_tools\n";
-    }
-}
-
 sub check_for_mig_tracking_table {
     my $dbh = db_connect();
     my $sth = $dbh->prepare("
index 4672e6d..7557168 100755 (executable)
@@ -42,9 +42,6 @@ if (! KMig::check_for_db_migschema()) {
     die "could not find the schema";
 }
 
-if (! KMig::check_db_migschema_for_migration_tables()) {
-    try_to_init_schema_with_migration_tools();
-}
 KMig::die_if_mig_tracking_table_exists();
 KMig::die_if_mig_column_tracking_table_exists();
 loop_through_mig_sql_templates();
@@ -53,19 +50,6 @@ exit 0;
 
 ###############################################################################
 
-sub try_to_init_schema_with_migration_tools {
-    KMig::die_if_no_migration_tools();
-    print "Calling mt_init() and mt_build()\n";
-    my $dbh = KMig::db_connect();
-    my $rv = $dbh->do("SELECT mt_init();")
-        || die "Error running mt_init(): $!\n";
-    print "mt_init() finished\n";
-    my $rv2 = $dbh->do("SELECT mt_build();")
-        || die "Error running mt_build(): $!\n";
-    print "migration_tools.build() finished\n";
-    KMig::db_disconnect($dbh);
-}
-
 sub loop_through_mig_sql_templates {
     print "Looping through kmig.d/sql/init/ templates\n";
     opendir my $dir, $mig_sql or die "Cannot open directory: $!";
diff --git a/kmig.d/sql/init/001-koha-staging-tables.sql b/kmig.d/sql/init/001-koha-staging-tables.sql
new file mode 100644 (file)
index 0000000..76580d1
--- /dev/null
@@ -0,0 +1,2 @@
+CREATE TABLE m_borrowers LIKE borrowers;
+CREATE TABLE m_items LIKE items;