I'm doing the todo tutorial of Play. When I created the evolution in conf/evolutions/default/1.sql
nothing happens. I just get the Exception JdbcSQLException: Table "TASK" not found
which makes sense.
I applied the evolution manually to the DB with h2-browser
in activator console and after that it works. But the evolutions don't show up automatically.
application.conf
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
db.default.username=sa
db.default.password=""
# New
evolutionplugin=enabled
applyEvolutions.db=true
applyEvolutions.default=true
applyDownEvolutions.default=true
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# play.evolutions.enabled=false
# You can disable evolutions for a specific datasource if necessary
# play.evolutions.db.default.enabled=false
1.sql
# Tasks schema
# --- !Ups
CREATE SEQUENCE task_id_seq;
CREATE TABLE task (
id integer NOT NULL DEFAULT nextval('task_id_seq'),
label varchar(255)
);
# --- !Downs
DROP TABLE task;
DROP SEQUENCE task_id_seq;
Ok. I read the migration docs and one has to apply libraryDependencies += evolutions
to build.sbt.
Then it works like expected.
These are not necessary, they will apply the evolution automatically (without showing the Database 'default' needs evolution!
):
applyEvolutions.db=true
applyEvolutions.default=true
applyDownEvolutions.default=true
Just an update for Play 2:
play.evolutions.enabled = true
play.evolutions.autoApply=true
play.evolutions.autoApplyDowns=true
来源:https://stackoverflow.com/questions/32561626/play-framework-2-4-3-evolutions-not-triggered