【问题标题】:Play 2.1 framework not detecting evolution changesPlay 2.1 框架未检测到进化变化
【发布时间】:2013-04-06 17:47:47
【问题描述】:

在将@ManyToMany 连接表添加到两个模型(在本例中为 User 和 Article 模型[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 没有检测到它对需要应用的数据库架构进行了更改?

【问题讨论】:

  • 您在生产或开发环境中遇到过这个问题吗?
  • 开发中,该应用目前尚未生产。

标签: playframework-2.0 ebean playframework-evolutions


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2013-05-17
    • 1970-01-01
    • 2021-06-18
    • 1970-01-01
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    相关资源
    最近更新 更多