Skip to content

[8.x] Allow turning evolutions script generation on or off per Ebean server - #902

Merged
mkurz merged 3 commits into
playframework:8.xfrom
mkurz:ebean-db-settings-8.x
Oct 8, 2026
Merged

mkurz merged 3 commits into
playframework:8.xfrom
mkurz:ebean-db-settings-8.x

Conversation

@mkurz

@mkurz mkurz commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Turn evolutions script generation on or off per Ebean server

play.ebean.generateEvolutionsScripts turns the generation of the evolutions scripts (conf/evolutions/<server>/1.sql, in dev and test mode) on or off for all Ebean servers. The new play.ebean.db.<server>.generateEvolutionsScripts setting overrides it for a single Ebean server, in both directions:

# Don't generate the scripts of the Ebean servers...
play.ebean.generateEvolutionsScripts = false
# ...except the one of the "default" Ebean server
play.ebean.db.default.generateEvolutionsScripts = true

For example, for:

  • a read-only database used as its own Ebean server (EbeanPlugin: Add support for read-only data-sources #118)
  • a database whose evolutions come from the classpath (e.g. from a dependency): Play's evolutions reader looks for conf/evolutions/<name>/1.sql on the filesystem first, so a generated file shadows these scripts
  • a database to which Play shouldn't apply evolutions (play.evolutions.db.<name>.enabled = false), but whose generated script is still wanted, e.g. for a DBA

That's why the setting is independent of Play's play.evolutions.db.<name>.enabled. Nothing changes unless the new setting is used.

Until now, the only per-database way was to remove the -- Created by Ebean DDL header from conf/evolutions/<name>/1.sql (or to create that file with other content), after which Play Ebean doesn't touch it anymore. The docs now explain both that and the new settings.

EbeanConfig gets a new generateEvolutionsScripts(String server) default method, which falls back to generateEvolutionsScripts(), so custom implementations keep working. DefaultEbeanConfig and EbeanParsedConfig keep their existing constructors.

Move the read replica setting to play.ebean.db.<server>

So that all settings of a single Ebean server live in one place, like Play's own play.evolutions.db.<name> settings, the read replica setting from #892 moves from play.ebean.readOnlyDatasources.<server> to play.ebean.db.<server>.readOnlyDatasource. It has not been released yet, so only snapshot users need to rename it.

Testing

  • New EbeanEvolutionsScriptsTest with two Ebean servers, each with its own model: scripts get generated for both by default (with Play's evolutions disabled, so that's independent), for none when turned off globally, and selectively when overridden per server in either direction; an unknown Ebean server name fails at startup. The two per-server tests fail without the change. For this, the build now enhances the models of the tests too.
  • New parsing tests in EbeanParsedConfigTest; EbeanReadOnlyDatasourceTest uses the renamed setting.
  • The existing tests with an empty models list now turn off the script generation: without configured models, Ebean searches the classpath and would pick up the new test models, writing conf/evolutions/default/1.sql into the working directory.
  • MiMa and the docs tests pass.

mkurz added 2 commits October 8, 2026 13:34
Rename play.ebean.readOnlyDatasources.<server> to
play.ebean.db.<server>.readOnlyDatasource, so that all settings of a
single Ebean server live in one place, like Play's own
play.evolutions.db.<name> settings. The previous setting has not been
released yet.
play.ebean.generateEvolutionsScripts turns the generation of the
evolutions scripts on or off for all Ebean servers. The new
play.ebean.db.<server>.generateEvolutionsScripts setting overrides it
for a single Ebean server, in both directions, e.g. to not generate a
script for a read-only database, or for a database whose evolutions
come from the classpath, which a generated conf/evolutions file would
shadow.

This is independent of Play's play.evolutions.db.<name>.enabled
setting, and nothing changes unless the new setting is used. Custom
EbeanConfig implementations keep working, as the new per-server method
defaults to the global setting.
Without any configured models, Ebean searches the classpath for them,
and finds the models of the new evolutions scripts test. So the tests
using an empty models list wrote conf/evolutions/default/1.sql into the
working directory.
@mergify

mergify Bot commented Oct 8, 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 533f767 into playframework:8.x Oct 8, 2026
21 checks passed
@mkurz
mkurz deleted the ebean-db-settings-8.x branch October 8, 2026 11:53
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.

1 participant