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;
cjds
  • 8,268
  • 10
  • 49
  • 84

2 Answers2

3

You are using an MySQL syntax.
Could you post your SQL? I suspect you use

INTEGER NOT NULL AUTO_INCREMENT

While you should use

SERIAL PRIMARY KEY
  • 1
    I'm not using anything explicitly. This is with the default 1.sql evolution generated by play. Is there anything (short of rewriting the whole evolution myself) that I can do . PS Question Edited – cjds Jul 07 '13 at 11:04
  • I'm not sure as I disabled evolution. I could be that in your case "Heroku" doesn't regenerate the evolution script and uses the MySQL version. Here's someone with a similar http://stackoverflow.com/questions/10806926/regenerate-evolution-scripts-in-play-2, hope you can solve it I'm out of ideas. –  Jul 07 '13 at 11:17
3

I finally got it done.

Apparently Heroku does NOT regenerate the evolution script (which doesn't really make sense)

Best option is to switch your development to POSTGRESQL

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

For anybody that might want some guidance on how to do that

  1. Change Build.scala add the dependency

        "postgresql" % "postgresql" % "9.1-901-1.jdbc4"
    
  2. Change 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. Run the play app and allow the evolution to happen

  4. Commit to the git, push it again and be happy.

cjds
  • 8,268
  • 10
  • 49
  • 84