Play framework 2.4.3 evolutions not triggered

血红的双手。 提交于 2019-12-07 16:55:26

问题


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;

回答1:


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



回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!