Skip to content

Generated evolution scripts in projects without Play's layout #930

Open

Description

@mkurz

In a project that disables Play's layout (disablePlugins(PlayLayoutPlugin)), the resources are in src/main/resources instead of conf. With a simple play.evolutions[.db.<name>].path, like the default evolutions, Play's evolutions still look for the scripts in conf/<path>/<name>/ on the filesystem first, and only then on the classpath, and Play Ebean writes the generated script to conf/<path>/<name>/1.sql as well. So:

  • The generated script doesn't get packaged, so it's missing in production.
  • In dev and test mode, it takes precedence over a hand-written src/main/resources/evolutions/<name>/1.sql, which then only production uses.

The docs (#931) describe workarounds: generate the script into ./src/main/resources/evolutions in dev and test mode, and use the default path in production; or turn off generating the script, and delete a generated copy.

Proper support would need to know where the project's resources really are, e.g. from the sbt plugin. Guessing it from which folders exist doesn't work: it can't tell a conf folder that Play Ebean created itself apart, misses custom resource directories, and can change which script Play applies.

Found while looking into #1.

Activity

  1. PromanSEW commented on Oct 13, 2026

    @PromanSEW
    Contributor

    In PlayService project I use this setting:

    devSettings ++= Seq(
          ("play.evolutions.path", "./src/main/resources/evolutions")
    )
  2. mkurz commented on Oct 13, 2026

    @mkurz
    MemberAuthor

    Thanks, that's a nicer variant: with devSettings, only sbt run uses ./src/main/resources/evolutions, and production keeps the default path, so it applies the packaged script without any override. I checked it with an application without Play's layout: in dev mode, Play Ebean writes src/main/resources/evolutions/default/1.sql, and the staged application applies it.

    One thing to be aware of: devSettings only apply to sbt run, not to sbt test. In tests, Play Ebean still writes conf/evolutions/default/1.sql, and the tests apply that copy. To use the same location in tests, set the path in the test application's configuration too, e.g. new GuiceApplicationBuilder().configure("play.evolutions.path", "./src/main/resources/evolutions").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions