play framewok postgresql:数据库'默认'需要进化

时间:2017-04-28 09:09:31

标签: postgresql heroku playframework

我通过以下教程

在heroku中部署了我非常简单的应用程序

当我通过sbt run运行它时,它在我的localhost中运行良好 但它在heroku上崩溃了!

这是我的1.sql:

# --- !Ups

create table contact (
  id                            SERIAL UNIQUE,
  name                          varchar(255),
  email                         varchar(255),
  phone                         varchar(255),
  constraint pk_contact primary key (id)
);
create sequence contact_seq;


# --- !Downs

drop table if exists contact;
drop sequence if exists contact_seq;

heroku的日志:

p.a.d.DefaultDBApi - Database [default] connected at jdbc:postgresql://...


!!! WARNING! This script contains DOWNS evolutions that are likely destructive
 [warn] p.a.d.e.ApplicationEvolutions - Your production database [default] needs evolutions, including downs!

drop table if exists contact;
 # --- Rev:1,Downs - a56ada6
 name                          varchar(255),
 drop sequence if exists contact_seq;
 email                         varchar(255), phone                         varchar(255),
# --- Rev:1,Ups - 53110fe
 create table contact (
 );
 id                            SERIAL UNIQUE,
 constraint pk_contact primary key (id)
 create sequence contact_seq;

 [warn] p.a.d.e.ApplicationEvolutions - Run with -Dplay.evolutions.db.default.autoApply=true and -Dplay.evolutions.db.default.autoApplyDowns=true if you want to run them automatically, including downs (be careful, especially if your down evolutions drop existing data)
 [info] application - ApplicationTimer demo: Starting application at 2017-04-28T08:59:05.048Z
 Oops, cannot start the server.
 @73o5pe90c: Database 'default' needs evolution!

我还补充道 play.evolutions.db.default.autoApply =真 在我的aplication.conf结束时

1 个答案:

答案 0 :(得分:1)

使用

运行
 -Dplay.evolutions.db.default.autoApply=true 

 -Dplay.evolutions.db.default.autoApplyDowns=true 

如果你想自动运行它们,包括下降(小心,特别是如果你的下降演变会丢失现有数据)。

您可以通过以下方式设置:

heroku config:set JAVA_OPTS="-Dplay.evolutions.db.default.autoApply=true -Dplay.evolutions.db.default.autoApplyDowns=true"