Java.DBMigrationTools.What is the purpose of include and includeAll in changelogs?

Short Answer

  • **<include>** lets you include one specific changelog file into another
  • **<includeAll>** lets you include all changelogs from a folder, automatically

This helps you modularize and organize your migrations across many files..

🔎 Detailed Explanation

🔹 include

Used to include a single specific file inside another changelog:

<include file="tables/users.xml" relativeToChangelogFile="true"/>

✅ Use this when you want explicit control over the load order
✅ Often used in a master changelog that lists all migration files

🔹 includeAll

Used to include all changelogs in a directory, in sorted order:

<includeAll path="tables/" relativeToChangelogFile="true"/>

✅ Includes all changelogs from the tables/ directory
✅ Files are loaded in alphabetical order
✅ Convenient when managing many small changelogs

🧠 Use Cases

Use CaseUse include or includeAll
Want full control over migration orderinclude
Want to auto-include all scripts in a folderincludeAll
Team adds changelogs frequently in parallelincludeAll for flexibility
Production migrations in strict orderinclude for safety

⚠️ Caution with includeAll

  • ❗ Ordering is by file name, so use naming like V001_init.xml, V002_add_index.xml
  • ❗ May re-include deleted files if you don’t clean up unused changelogs

📌 Key Takeaways

✅ Use <include> to add one changelog file, with manual order control
✅ Use <includeAll> to add all changelogs from a directory, automatically sorted
✅ Modularization improves maintainability, especially in large projects

This entry was posted in Без рубрики. Bookmark the permalink.