001package io.ebean.migration.auto; 002 003import javax.sql.DataSource; 004import java.util.Properties; 005 006/** 007 * Automatically run DB Migrations on application start. 008 */ 009public interface AutoMigrationRunner { 010 011 /** 012 * Set the name of the database the migration is run for. 013 * <p> 014 * This name can be used when loading properties like: 015 * <code>ebean.${name}.migration.migrationPath</code> 016 */ 017 void setName(String name); 018 019 /** 020 * Set a default DB schema to use. 021 * <p> 022 * This is mostly for Postgres use where the dbSchema matches the DB username. In this case 023 * we don't set the current schema as that can mess up the Postgres search path. 024 * </p> 025 */ 026 void setDefaultDbSchema(String defaultDbSchema); 027 028 /** 029 * Load configuration properties. 030 */ 031 void loadProperties(Properties properties); 032 033 /** 034 * Set the platform for running the migration. 035 * <p> 036 * In the case where we have migrations for many platforms this defines the associated platform 037 * that is being used to run the migration. 038 */ 039 default void setPlatform(String platform) { 040 // do nothing by default 041 } 042 043 /** 044 * Set the base platform for running the migration. 045 * <p> 046 * For example, with sqlserver17 the base platform is "sqlserver" and platform is "sqlserver17". 047 * Similarly, with db2luw the base platform is "db2" and the platform is "db2luw". 048 * <p> 049 * The migration runner can look for migrations to run based on the base platform or specific platform. 050 */ 051 default void setBasePlatform(String basePlatform) { 052 // do nothing by default 053 } 054 055 /** 056 * Run DB migrations using the given DataSource. 057 */ 058 void run(DataSource dataSource); 059}