1

所以我玩了 2.0.4 项目,我想把它推到 heroku 上。该项目使用 play authenticate 插件,并且在本地一切正常,所以我尝试将其推送到 heroku。

我花了几个小时试图让它现在工作,但运气不佳。

所以我修改了我的application.conf:

#db.default.driver=org.h2.Driver
db.default.url="the url for my postgres database"
# db.default.user=sa
# db.default.password=

修改了我的 Procfile:

web: target/start -Dhttp.port=${PORT} -Dplay.version=2.0.4 -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=$DATABASE_URL ${JAVA_OPTS}

在我的应用程序依赖项中包含 postgresl:

val appDependencies = Seq(
  "be.objectify"  %%  "deadbolt-2"        % "1.1.3-SNAPSHOT",
  "com.feth"      %%  "play-authenticate" % "0.2.2-SNAPSHOT",
  "postgresql"    %   "postgresql"        % "9.1-901.jdbc4"
)

我在 conf/evolutions/1.sql 中有一个数据库演化:

# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions

# --- !Ups

create table journey (
  id                        bigint not null,
  s_lat                     varchar(255),
  s_lon                     varchar(255),
  e_lat                     varchar(255),
  e_lon                     varchar(255),
  start_loc                 varchar(255),
  end_loc                   varchar(255),
  participant_type          varchar(255),
  date                      varchar(255),
  time                      varchar(255),
  user                      varchar(255),
  constraint pk_journey primary key (id))
;

create table linked_account (
  id                        bigint not null,
  user_id                   bigint,
  provider_user_id          varchar(255),
  provider_key              varchar(255),
  constraint pk_linked_account primary key (id))
;

create table security_role (
  id                        bigint not null,
  role_name                 varchar(255),
  constraint pk_security_role primary key (id))
;

create table token_action (
  id                        bigint not null,
  token                     varchar(255),
  target_user_id            bigint,
  type                      varchar(2),
  created                   timestamp,
  expires                   timestamp,
  constraint ck_token_action_type check (type in ('EV','PR')),
  constraint uq_token_action_token unique (token),
  constraint pk_token_action primary key (id))
;

create table users (
  id                        bigint not null,
  email                     varchar(255),
  name                      varchar(255),
  last_login                timestamp,
  active                    boolean,
  email_validated           boolean,
  constraint pk_users primary key (id))
;

create table user_permission (
  id                        bigint not null,
  value                     varchar(255),
  constraint pk_user_permission primary key (id))
;


create table users_security_role (
  users_id                       bigint not null,
  security_role_id               bigint not null,
  constraint pk_users_security_role primary key (users_id, security_role_id))
;

create table users_user_permission (
  users_id                       bigint not null,
  user_permission_id             bigint not null,
  constraint pk_users_user_permission primary key (users_id, user_permission_id))
;
create sequence journey_seq;

create sequence linked_account_seq;

create sequence security_role_seq;

create sequence token_action_seq;

create sequence users_seq;

create sequence user_permission_seq;

alter table linked_account add constraint fk_linked_account_user_1 foreign key (user_id) references users (id) on delete restrict on update restrict;
create index ix_linked_account_user_1 on linked_account (user_id);
alter table token_action add constraint fk_token_action_targetUser_2 foreign key (target_user_id) references users (id) on delete restrict on update restrict;
create index ix_token_action_targetUser_2 on token_action (target_user_id);



alter table users_security_role add constraint fk_users_security_role_users_01 foreign key (users_id) references users (id) on delete restrict on update restrict;

alter table users_security_role add constraint fk_users_security_role_securi_02 foreign key (security_role_id) references security_role (id) on delete restrict on update restrict;

alter table users_user_permission add constraint fk_users_user_permission_user_01 foreign key (users_id) references users (id) on delete restrict on update restrict;

alter table users_user_permission add constraint fk_users_user_permission_user_02 foreign key (user_permission_id) references user_permission (id) on delete restrict on update restrict;

# --- !Downs

SET REFERENTIAL_INTEGRITY FALSE;

drop table if exists journey;

drop table if exists linked_account;

drop table if exists security_role;

drop table if exists token_action;

drop table if exists users;

drop table if exists users_security_role;

drop table if exists users_user_permission;

drop table if exists user_permission;

SET REFERENTIAL_INTEGRITY TRUE;

drop sequence if exists journey_seq;

drop sequence if exists linked_account_seq;

drop sequence if exists security_role_seq;

drop sequence if exists token_action_seq;

drop sequence if exists users_seq;

drop sequence if exists user_permission_seq;

我执行以下命令并尝试推送到 heroku(在我的 repo 目录中):

git init
git add .
git commit -m "init"
git push heroku master

尝试加载应用程序时,日志如下所示:

2013-05-04T00:57:46.690449+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
2013-05-04T00:57:47.503897+00:00 app[web.1]: Play server process ID is 2
2013-05-04T00:57:49.206353+00:00 app[web.1]: [[37minfo[0m] play - database [default] connected at jdbc:postgresql://ec2-54-235-155-40.compute-1.amazonaws.com:5432/d8837fesm242q7
2013-05-04T00:57:53.439981+00:00 app[web.1]: Oops, cannot start the server.
2013-05-04T00:57:53.439981+00:00 app[web.1]:   Position: 23 

2013-05-04T00:57:53.439981+00:00 app[web.1]: Query was:

2013-05-04T00:57:53.439981+00:00 app[web.1]: javax.persistence.PersistenceException: Query threw SQLException:ERROR: relation "security_role" does not exist
2013-05-04T00:57:53.439981+00:00 app[web.1]: Bind values:[] 

2013-05-04T00:57:53.439981+00:00 app[web.1]: from security_role t0 

.....MORE LOGS ....

2013-05-04T00:57:53.442045+00:00 app[web.1]: Caused by: org.postgresql.util.PSQLException: ERROR: relation "security_role" does not exist
2013-05-04T00:57:53.442283+00:00 app[web.1]:    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
2013-05-04T00:57:53.442149+00:00 app[web.1]:   Position: 23


.... MORE LOGS .....

2013-05-04T00:57:55.121895+00:00 heroku[web.1]: State changed from starting to crashed
2013-05-04T00:57:55.110448+00:00 heroku[web.1]: Process exited with status 255
2013-05-04T01:01:06.387417+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=serene-crag-5945.herokuapp.com fwd="82.24.103.61" dyno= connect= service= status=503 bytes=

我觉得我已经尝试了一切,包括重置 heroku 数据库。我尝试在没有默认演变的情况下推送应用程序,但仍然遇到相同的错误。我不确定它是否与错误提示的 play-authenticate 模块有关,但我怀疑它,因为它在本地使用 H2 数据库工作而没有错误。

4

0 回答 0