2013-04-06 36 views
2

在两个模型(本例中为User和Article模型[1])上添加@ManyToMany连接表后,Play会正确检测这些更改并相应地修改1.sql [2]文件:Play 2.1框架未检测到进化变化

[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; 

但是打开使用这种关系页面时,将显示演变需要申请,而不是呈现以下错误无消息:

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

为什么玩不检测,它已经做了修改需要应用的数据库模式?

+0

在生产或开发环境中,您有这个问题吗? – MaFo 2013-04-07 13:15:50

+0

开发,该应用程序目前尚未投入生产。 – HaaR 2013-04-07 14:57:46

回答

2

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

+0

是的,你是对的。这个对我有用。 – BalaB 2015-04-03 18:14:02