-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
platform directories not respected when applying migrations generated for multiple platforms #162
Comments
I tried setting |
The issue here is with running the migrations ... but you haven't show us any code for running the migrations? Are you running the migrations declaratively? Or how are you running the migrations? |
oh, right, sorry about that. this is how we run them: const val INDEX_DB_NAME = "index"
const val INDEX_DB_QUALIFIER = "indexDatabase"
@Configuration
@Import(JacksonAutoConfiguration::class)
class IndexPersistenceConfiguration {
// example yaml:
// datasource:
// index:
// username: sa
// password: sa
// url: jdbc:h2:mem:indexdb
// driver: org.h2.Driver
@Bean
@ConfigurationProperties(prefix = "datasource.$INDEX_DB_NAME")
fun indexDataSourceConfig() = DataSourceConfig().also {
it.addProperty("quoteReturningIdentifiers", false)
}
// example yaml:
// database:
// index:
// ddl-run: false
// ddl-generate: false
// ddl-migrate: true
@Bean
@ConfigurationProperties(prefix = "database.$INDEX_DB_NAME")
fun indexDatabaseConfig(
objMapper: ObjectMapper,
@Qualifier("indexDataSourceConfig") dsConfig: DataSourceConfig,
) = DatabaseConfig().also {
it.name = INDEX_DB_NAME
it.objectMapper = objMapper
it.isDefaultServer = false
it.packages = listOf(
"cz.sentica.qwazar.kb.modules.dora.qstore.resources",
// ...
)
it.setDataSourceConfig(dsConfig)
}
@Bean(name = [INDEX_DB_QUALIFIER], destroyMethod = "")
fun indexDatabase(
@Qualifier("indexDatabaseConfig") dbConfig: DatabaseConfig,
@Value("\${database.$INDEX_DB_NAME.ddl-migrate:false}") migrate: Boolean,
): Database = DatabaseFactory.create(dbConfig).also {
if (migrate) {
val migrationConfig = MigrationConfig().apply {
// otherwise ALL migrations (for all platforms) are applied
val platformDir = it.platform().base().name.lowercase()
migrationPath = "dbmigration/$INDEX_DB_NAME/$platformDir"
}
MigrationRunner(migrationConfig).run(it.dataSource())
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys. We just started experimenting with ebean-migration and encountered some problems. We have a migration generation script like this:
this correctly generates a directory structure like this
then when I'm trying to apply these migrations in H2, all of the SQL files (not just the two H2-specific ones) are found and attempted to be applied, as you can see in this debugger screenshot
And this results in the following error when applying
I__create_procs.sql
(which is SQL server specific!):I guess I can work around this by setting a narrower
migrationPath
, but then this code would have to be changed btw platforms.The text was updated successfully, but these errors were encountered: