playframework-2.0 - Play 2.1 框架未检测进化变化

标签 playframework-2.0 ebean playframework-evolutions

将 @ManyToMany 连接表添加到两个模型(在本例中为用户模型和文章模型[1])时,Play 会正确检测到这些更改并相应地修改 1.sql[2] 文件:

[1]
+    @ManyToMany
+    public List<User> authors;

+    @ManyToMany(mappedBy="authors")
+    public List<Article> authoredArticles;

[2]
+    create table articles_users (
+      articles_id                    bigint not null,
+      users_id                       bigint not null,
+      constraint pk_articles_users primary key (articles_id, users_id)
+    );

+    alter table articles_users add constraint fk_articles_users_articles_01 foreign key (articles_id) references articles (id);
+    alter table articles_users add constraint fk_articles_users_users_02 foreign key (users_id) references users (id);

# --- !Downs

+    drop table if exists articles_users cascade;

但是,当打开使用此关系的页面时,不会显示有关需要应用 Evolutions 的消息,而是出现以下错误:

PersistenceException: Query threw SQLException:ERROR: relation "articles_users" does not exist

为什么 Play 没有检测到它对需要应用的数据库架构进行了更改?

最佳答案

检查 play_evolutions 表,如果已经有 id 1 的行,则必须将 sql 文件重命名为 2.sql 或手动删除表。

关于playframework-2.0 - Play 2.1 框架未检测进化变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15854112/

相关文章:

postgresql - 无法在 Play 框架演变中执行创建 postgres 函数

playframework - 如何为 Play 2 Framework 生成 keystore ?

java - 无法在 PLAY 2.0 中使用外键创建复合主键

java - 玩! 2.0 覆盖 "Invalid Value"消息

java - Play Framework 2 Ebean 为字段指定默认值

hibernate - Play Framework 2.4 中的 Play Evolutions 和 JPA

java - Ebean 和 ManyToOne 建议

scala - 如何将隐式 Action val 覆盖到 Play 框架 2 中

internationalization - play framework 2.0 - 国际化 - 如何翻译消息