gpt4 book ai didi

playframework - 未触发 Play Framework 2.4.3 演变

转载 作者:行者123 更新时间:2023-12-04 05:51:46 25 4
gpt4 key购买 nike

我正在做 todo tutorial玩。当我在 conf/evolutions/default/1.sql 中创建 evolution 时,没有任何反应。我刚得到异常 JdbcSQLException: Table "TASK"not found 这是有道理的。

我在激活器控制台中使用 h2-browser 将进化手动应用到数据库,然后它就可以工作了。但进化不会自动显示。

应用程序.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;

最佳答案

好的。我读了migration docs并且必须将 libraryDependencies += evolutions 应用于 build.sbt。

然后它按预期工作。

这些不是必需的,它们会自动应用进化(不显示数据库“默认”需要进化!):

applyEvolutions.db=true
applyEvolutions.default=true
applyDownEvolutions.default=true

关于playframework - 未触发 Play Framework 2.4.3 演变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32561626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com