Skip to content

Write the generated evolution script to absolute evolution paths, and explain projects without Play's layout - #931

Merged
mkurz merged 2 commits into
playframework:mainfrom
mkurz:evolutions-absolute-path
Oct 13, 2026
Merged

mkurz merged 2 commits into
playframework:mainfrom
mkurz:evolutions-absolute-path

Conversation

@mkurz

@mkurz mkurz commented Oct 13, 2026

Copy link
Copy Markdown
Member
  • With an absolute play.evolutions[.db.<name>].path, Play's evolutions read the scripts from that path as it is, but Play Ebean resolved it relative to the application's root folder. So it wrote the generated script to e.g. <root>/opt/migrations/default/1.sql instead of /opt/migrations/default/1.sql, where Play didn't find it, and it didn't see a hand-written script there. Play Ebean now resolves the path like Play's evolutions do.
  • The new EbeanEvolutionsScriptPathTest starts an application for each kind of path (default, a folder in conf, ./…, ../…, absolute), and checks that Play applies the generated script, and that there is no other copy of it. It also checks that a hand-written script in an absolute folder stays untouched and gets applied. Without the fix, the two tests with an absolute path fail.
  • The docs now say that Play Ebean follows the location of the evolution scripts, and explain what to do in a project that disables Play's layout. There, Play still looks for the scripts in conf first, but doesn't package that folder, so the generated script is missing in production, and in dev and test mode it takes precedence over a script in src/main/resources. Automatic support for that is tracked in Generated evolution scripts in projects without Play's layout #930.

Fixes #1, together with #387, which made the location configurable.

mkurz added 2 commits October 13, 2026 12:26
With an absolute `play.evolutions[.db.<name>].path`, Play's evolutions read the scripts from that path as it is, but Play Ebean resolved it relative to the application's root folder, like any other path. So it wrote the script to e.g. `<root>/opt/migrations/default/1.sql` instead of `/opt/migrations/default/1.sql`, where Play didn't find it, and it didn't see a hand-written script there.

Play Ebean now resolves the path like Play's evolutions do. The new test checks for each kind of path that Play applies the generated script, and that a hand-written script in an absolute folder stays untouched.
…ay's layout

Play Ebean follows the location of the evolution scripts that Play's evolutions use. In a project that disables Play's layout, Play still looks for the scripts in `conf` first, but doesn't package that folder, so the generated script is missing in production, and it takes precedence over the user's script in `src/main/resources` in dev and test mode. The docs show how to generate the script into the resources instead, or to turn off generating it.
@mergify

mergify Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@mkurz
mkurz merged commit 5236c2a into playframework:main Oct 13, 2026
80 checks passed
@mkurz
mkurz deleted the evolutions-absolute-path branch October 13, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix hardcoded references to conf directory

1 participant