Play框架2.4.3演变未触发 [英] Play framework 2.4.3 evolutions not triggered
问题描述
我正在做玩游戏的教程.当我在conf/evolutions/default/1.sql
中创建演变时,什么都没有发生.我刚刚得到了有意义的异常JdbcSQLException: Table "TASK" not found
.
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.
我使用激活器控制台中的h2-browser
将演变手动应用于数据库,然后它起作用了.但是进化不会自动出现.
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
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;
推荐答案
好.我阅读了迁移文档,必须将libraryDependencies += evolutions
应用于build.sbt
Ok. I read the migration docs and one has to apply libraryDependencies += evolutions
to build.sbt.
然后它像预期的那样工作.
Then it works like expected.
这些不是必需的,它们将自动应用演变(不显示Database 'default' needs evolution!
):
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
这篇关于Play框架2.4.3演变未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!