I figure it out the issue by commenting out some of the table schema in Tables.scala. I have multiple tables declared in Table object and one of them is not existed in the database, for example:
object Tables extends ActiveRecordTables with PlaySupport {
val users = Table[User]
val role = Table[Role]
val group = Table[Group] //not exist which cause the error!
}
If one of the table is not exist in the database, the framework will create ALL tables in the order that listed in the object.
I did try to arrange the non-existing record to the top and the framework would create the table and failed to run. However, if a situation as listed above, it would give error: table 'user' is already declared and NO table would be created in database.
Copied here from http://stackoverflow.com/a/17098076/472262
Stacktrace:
[error] application -
! @6mf36n5bm - Internal server error, for (OPTIONS) [/me] ->
play.api.UnexpectedException: Unexpected exception[SquerylSQLException: error executing create table `users` (
`headline` varchar(128),
`created_on` date not null,
`gender` int
)
java.sql.SQLSyntaxErrorException: Table 'users' already exists]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:166) ~[play_2.11-2.3.9.jar:2.3.9]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.9.jar:2.3.9]
at scala.Option.map(Option.scala:146) ~[scala-library-2.11.6.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130) ~[play_2.11-2.3.9.jar:2.3.9]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:128) ~[play_2.11-2.3.9.jar:2.3.9]
Caused by: org.squeryl.SquerylSQLException: error executing create table `users` (
`headline` varchar(128),
`created_on` date not null,
`gender` int
)
java.sql.SQLSyntaxErrorException: Table 'users' already exists
at org.squeryl.SquerylSQLException$.apply(KeyedEntity.scala:118) ~[squeryl_2.11-0.9.6-RC3.jar:0.9.6-RC3]
at org.squeryl.Schema.org$squeryl$Schema$$_executeDdl(Schema.scala:247) ~[squeryl_2.11-0.9.6-RC3.jar:0.9.6-RC3]
at org.squeryl.Schema$$anonfun$_createTables$1.apply(Schema.scala:275) ~[squeryl_2.11-0.9.6-RC3.jar:0.9.6-RC3]
at org.squeryl.Schema$$anonfun$_createTables$1.apply(Schema.scala:272) ~[squeryl_2.11-0.9.6-RC3.jar:0.9.6-RC3]
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59) ~[scala-library-2.11.6.jar:na]
Caused by: java.sql.SQLSyntaxErrorException: Table 'users' already exists
at org.mariadb.jdbc.internal.SQLExceptionMapper.get(SQLExceptionMapper.java:138) ~[mariadb-java-client-1.1.8.jar:na]
at org.mariadb.jdbc.internal.SQLExceptionMapper.throwException(SQLExceptionMapper.java:106) ~[mariadb-java-client-1.1.8.jar:na]
at org.mariadb.jdbc.MySQLStatement.executeQueryEpilog(MySQLStatement.java:268) ~[mariadb-java-client-1.1.8.jar:na]
at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:296) ~[mariadb-java-client-1.1.8.jar:na]
at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:346) ~[mariadb-java-client-1.1.8.jar:na]
Caused by: org.mariadb.jdbc.internal.common.QueryException: Table 'users' already exists
at org.mariadb.jdbc.internal.mysql.MySQLProtocol.getResult(MySQLProtocol.java:982) ~[mariadb-java-client-1.1.8.jar:na]
at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:1042) ~[mariadb-java-client-1.1.8.jar:na]
at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:289) ~[mariadb-java-client-1.1.8.jar:na]
at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:346) ~[mariadb-java-client-1.1.8.jar:na]
at com.jolbox.bonecp.StatementHandle.execute(StatementHandle.java:254) ~[bonecp-0.8.0.RELEASE.jar:na]
I figure it out the issue by commenting out some of the table schema in Tables.scala. I have multiple tables declared in Table object and one of them is not existed in the database, for example:
If one of the table is not exist in the database, the framework will create ALL tables in the order that listed in the object.
I did try to arrange the non-existing record to the top and the framework would create the table and failed to run. However, if a situation as listed above, it would give error: table 'user' is already declared and NO table would be created in database.
Copied here from http://stackoverflow.com/a/17098076/472262
Stacktrace: