核心源码阅读路径
执行的核心代码位置入口
spring-boot-autoconfigure包中:
org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer->afterPropertiesSet->migrate方法
一般会见到一些探测的问题,是在org.flywaydb.core.Flyway#doValidate类中里面做的
- 常见的问题
Caused by: org.flywaydb.core.api.FlywayException: Validate failed:
Detected resolved migration not applied to database: 001.002.001.001
具体的而校验逻辑是在:org.flywaydb.core.internal.command.DbValidate#validate 这个类进行的
校验过程中创建MigrationInfoServiceImpl,其中加载已有脚本是在org.flywaydb.core.internal.info.MigrationInfoServiceImpl#refresh这个方法执行的时候进行的
- 这块的逻辑是根据context的配置信息获取指定classpath的SQL脚本文件
Collection<ResolvedMigration> resolvedMigrations = migrationResolver.resolveMigrations(context);
- SQL脚本是否已经执行标识,后面新增的保存近pendingResolverVersioned。如果已经执行过的序号中间新增会报错
ResolvedMigration resolvedMigration = resolvedVersioned.get(Pair.of(av.getLeft().getVersion(), av.getLeft().getType().isUndo()));
if (resolvedMigration != null) {
pendingResolvedVersioned.remove(resolvedMigration);
}
标签:改动,版本控制,core,flyway,resolvedMigration,org,flywaydb
From: https://www.cnblogs.com/perfectLi/p/17613306.html