0

So I'm having a problem putting my play app on Heroku

Went through a couple of tutorials but couldn't get it to work.

My play app is getting displayed but the database for it is not getting created.

When I go through the logs this is coming

Database 'default' is in inconsistent state
....
Oops, cannot start the server.
.....
ERROR: syntax error at or near "auto_increment"

This is the configuration:

  1. In application.conf all database lines are commented

  2. 1.sql is the same as normal (no changes)

  3. Procfile is as follows

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

A shortened version of 1.sql is as follows (auto generated)

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

# --- !Ups

create table admin (
    user_id                   bigint auto_increment not null,
    user_name                 varchar(255),
    user_username             varchar(255),
    user_password             varchar(255),
    user_privelege_level      integer,
    user_type                 integer,
    admin_id                  bigint,
    constraint pk_admin primary key (user_id))
;

# --- a lot more tables

alter table class add constraint fk_class_classteacher_1 foreign key (classteacher_user_id) references teacher (user_id) on delete restrict on update restrict;
create index ix_class_classteacher_1 on class (classteacher_user_id);

# --- a lot more fks and indices

# --- !Downs

SET FOREIGN_KEY_CHECKS=0;
drop table admin;

drop table book;

# --- a lot more drops
SET FOREIGN_KEY_CHECKS=1;
4

2 回答 2

3

我终于完成了。

显然 Heroku 不会重新生成进化脚本(这实际上没有意义)

最好的选择是将您的开发切换到 POSTGRESQL

http://www.postgresql.org/download/

对于任何可能需要有关如何做到这一点的指导的人

  1. 更改 Build.scala 添加依赖

        "postgresql" % "postgresql" % "9.1-901-1.jdbc4"
    
  2. 更改 application.conf

      db.default.driver=org.postgresql.Driver
      db.default.url="jdbc:postgresql://servername:port/db_name"
      db.default.user=postgres
      db.default.password=pass
      # Remember to comment user and password while pushing because this will 
      # cause an error as Heroku doesn't automatically use theirs 
    
  3. 运行 play 应用程序并让进化发生

  4. 提交到 git,再次推送它并感到高兴。

于 2013-07-08T10:34:47.600 回答
3

您正在使用 MySQL 语法。
你能发布你的SQL吗?我怀疑你用

INTEGER NOT NULL AUTO_INCREMENT

虽然你应该使用

SERIAL PRIMARY KEY
于 2013-07-07T10:56:40.113 回答