schema_version テーブルを更新し、変更された PL/SQL パッケージ/手順をフライウェイでコードの重複なしに実行するには、どのような方法が望ましいでしょうか?
私の例では、PL/SQLコードの変更ごとにクラス・ファイルを作成する必要があります
public class V2_1__update_scripts extends AbstractMigration {
// update package and procedures
}
AbstractMigration クラスは、db/updateフォルダー内のファイルを実行します。
public abstract class AbstractMigration implements SpringJdbcMigration {
private static final Logger log = LoggerFactory.getLogger(AbstractMigration.class);
@Override
public void migrate(JdbcTemplate jdbcTemplate) throws Exception {
Resource packageFolder = new ClassPathResource("db/update");
Collection<File> files = FileUtils.listFiles(packageFolder.getFile(), new String[]{"sql"}, true);
for (File file : files ) {
log.info("Executing [{}]", file.getAbsolutePath());
String fileContents = FileUtils.readFileToString(file);
jdbcTemplate.execute(fileContents);
}
}
}
PL/SQLコードを実行するより良い方法はありますか?