// Path: src/main/java/com/github/arteam/jdit/maintenance/DatabaseMaintenance.java
// public interface DatabaseMaintenance {
// 
//     /**
//      * Drop all tables and sequences
//      */
//     void dropTablesAndSequences();
// 
//     /**
//      * Sweep data from the DB, but don't drop the schema.
//      * Also restart sequences, so tests can rely on their predictability.
//      */
//     void sweepData();
// }
// 
// Path: src/main/java/com/github/arteam/jdit/maintenance/DatabaseMaintenanceFactory.java
// public final class DatabaseMaintenanceFactory {
// 
//     private static final String POSTGRESQL = "PostgreSQL";
//     private static final String HSQLDB = "HSQL Database Engine";
//     private static final String H2 = "H2";
//     private static final String MYSQL = "MySQL";
// 
//     private DatabaseMaintenanceFactory() {
//     }
// 
//     public static DatabaseMaintenance create(Handle handle) {
//         String databaseVendor = getDatabaseVendor(handle);
//         switch (databaseVendor) {
//             case POSTGRESQL:
//                 return new PostgresDatabaseMaintenance(handle);
//             case HSQLDB:
//                 return new HsqlDatabaseMaintenance(handle);
//             case H2:
//                 return new H2DatabaseMaintenance(handle);
//             case MYSQL:
//                 return new MySqlDatabaseMaintenance(handle);
//             default:
//                 throw new UnsupportedOperationException(databaseVendor + " is not supported");
//         }
//     }
// 
//     private static String getDatabaseVendor(Handle handle) {
//         try {
//             return handle.getConnection().getMetaData().getDatabaseProductName();
//         } catch (SQLException e) {
//             throw new RuntimeException(e);
//         }
//     }
// }


import com.github.arteam.jdit.maintenance.DatabaseMaintenance;
import com.github.arteam.jdit.maintenance.DatabaseMaintenanceFactory;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Properties;
    }

    @SuppressWarnings("unchecked")
    private Comparator<String> createFilesComparator(Properties properties) {
        try {
            if (!properties.containsKey("schema.migration.file.comparator")) {
                return null;
            }
            return (Comparator<String>) Class.forName(properties.getProperty("schema.migration.file.comparator"))
                    .newInstance();
        } catch (Exception e) {
            throw new IllegalStateException("Unable to create a comparator", e);
        }
    }

    /**
     * Migrate the DB schema
     *
     * @param properties configuration of schema migration
     */
    private void migrateSchema(Properties properties) {
        String property = properties.getProperty("schema.migration.enabled");
        if (property != null && !Boolean.parseBoolean(property)) {
            return;
        }
        try (Handle handle = dbi.open()) {
            String schemaLocation = properties.getProperty("schema.migration.location");
            if (schemaLocation == null) {
                schemaLocation = DEFAULT_SCHEMA_LOCATION;
            }
// Path: src/main/java/com/github/arteam/jdit/maintenance/DatabaseMaintenance.java
// public interface DatabaseMaintenance {
// 
//     /**
//      * Drop all tables and sequences
//      */
//     void dropTablesAndSequences();
// 
//     /**
//      * Sweep data from the DB, but don't drop the schema.
//      * Also restart sequences, so tests can rely on their predictability.
//      */
//     void sweepData();
// }
// 
// Path: src/main/java/com/github/arteam/jdit/maintenance/DatabaseMaintenanceFactory.java
// public final class DatabaseMaintenanceFactory {
// 
//     private static final String POSTGRESQL = "PostgreSQL";
//     private static final String HSQLDB = "HSQL Database Engine";
//     private static final String H2 = "H2";
//     private static final String MYSQL = "MySQL";
// 
//     private DatabaseMaintenanceFactory() {
//     }
// 
//     public static DatabaseMaintenance create(Handle handle) {
//         String databaseVendor = getDatabaseVendor(handle);
//         switch (databaseVendor) {
//             case POSTGRESQL:
//                 return new PostgresDatabaseMaintenance(handle);
//             case HSQLDB:
//                 return new HsqlDatabaseMaintenance(handle);
//             case H2:
//                 return new H2DatabaseMaintenance(handle);
//             case MYSQL:
//                 return new MySqlDatabaseMaintenance(handle);
//             default:
//                 throw new UnsupportedOperationException(databaseVendor + " is not supported");
//         }
//     }
// 
//     private static String getDatabaseVendor(Handle handle) {
//         try {
//             return handle.getConnection().getMetaData().getDatabaseProductName();
//         } catch (SQLException e) {
//             throw new RuntimeException(e);
//         }
//     }
// }


// Path: src/main/java/com/github/arteam/jdit/DBIContext.java
import com.github.arteam.jdit.maintenance.DatabaseMaintenance;
import com.github.arteam.jdit.maintenance.DatabaseMaintenanceFactory;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.Properties;

    }

    @SuppressWarnings("unchecked")
    private Comparator<String> createFilesComparator(Properties properties) {
        try {
            if (!properties.containsKey("schema.migration.file.comparator")) {
                return null;
            }
            return (Comparator<String>) Class.forName(properties.getProperty("schema.migration.file.comparator"))
                    .newInstance();
        } catch (Exception e) {
            throw new IllegalStateException("Unable to create a comparator", e);
        }
    }

    /**
     * Migrate the DB schema
     *
     * @param properties configuration of schema migration
     */
    private void migrateSchema(Properties properties) {
        String property = properties.getProperty("schema.migration.enabled");
        if (property != null && !Boolean.parseBoolean(property)) {
            return;
        }
        try (Handle handle = dbi.open()) {
            String schemaLocation = properties.getProperty("schema.migration.location");
            if (schemaLocation == null) {
                schemaLocation = DEFAULT_SCHEMA_LOCATION;
            }
            DatabaseMaintenance databaseMaintenance = DatabaseMaintenanceFactory.create(handle);