Stuck in evolutions loop

364 views
Skip to first unread message

v6ak

unread,
May 4, 2011, 9:01:39 AM5/4/11
to play-framework
I've been playing with database. I've decided to move the H2 DB
outside the app from some reasons (e.g. it is annoying to have some
data in WAR). I got stuck in evolution loop (1. Click 'Apply
evolutions'; 2. go to step 1). I've tried play evolutions:apply, that
thrown an Exception (see below). I've tried to delete the DB file, but
with no success.

The terrible Exception that probably should have been handled:

org.h2.jdbc.JdbcSQLException: Tabulka "PLAY_EVOLUTIONS" již existuje
Table "PLAY_EVOLUTIONS" already exists; SQL statement:
create table play_evolutions (id int not null primary key, hash
varchar(255) not null, applied_at timestamp not null, apply_script
text, revert_script text, state varchar(255), last_problem text)
[42101-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.ddl.CreateTable.update(CreateTable.java:108)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:209)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:178)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:153)
at play.db.Evolutions.execute(Evolutions.java:451)
at play.db.Evolutions.listDatabaseEvolutions(Evolutions.java:404)
at play.db.Evolutions.main(Evolutions.java:54)
14:56:19,460 ERROR ~
org.h2.jdbc.JdbcSQLException: Tabulka "PLAY_EVOLUTIONS" již existuje
Table "PLAY_EVOLUTIONS" already exists; SQL statement:
create table play_evolutions (id int not null primary key, hash
varchar(255) not null, applied_at timestamp not null, apply_script
text, revert_script text, state varchar(255), last_problem text)
[42101-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.ddl.CreateTable.update(CreateTable.java:108)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:209)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:178)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:153)
at play.db.Evolutions.execute(Evolutions.java:451)
at play.db.Evolutions.listDatabaseEvolutions(Evolutions.java:404)
at play.db.Evolutions.getEvolutionScript(Evolutions.java:330)
at play.db.Evolutions.checkEvolutionsState(Evolutions.java:297)
at play.db.Evolutions.main(Evolutions.java:76)
~ Application revision is 1 [229648e] and Database revision is 0
[da39a3e]

v6ak

unread,
May 4, 2011, 9:06:48 AM5/4/11
to play-framework
Note that play evolutions:markApplied throws similar Exceptions:

15:04:59,691 ERROR ~
org.h2.jdbc.JdbcSQLException: Tabulka "PLAY_EVOLUTIONS" již existuje
Table "PLAY_EVOLUTIONS" already exists; SQL statement:
create table play_evolutions (id int not null primary key, hash
varchar(255) not null, applied_at timestamp not null, apply_script
text, revert_script text, state varchar(255), last_problem text)
[42101-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.ddl.CreateTable.update(CreateTable.java:108)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:209)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:178)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:153)
at play.db.Evolutions.execute(Evolutions.java:451)
at play.db.Evolutions.listDatabaseEvolutions(Evolutions.java:404)
at play.db.Evolutions.main(Evolutions.java:54)
15:04:59,705 ERROR ~
org.h2.jdbc.JdbcSQLException: Tabulka "PLAY_EVOLUTIONS" již existuje
Table "PLAY_EVOLUTIONS" already exists; SQL statement:
create table play_evolutions (id int not null primary key, hash
varchar(255) not null, applied_at timestamp not null, apply_script
text, revert_script text, state varchar(255), last_problem text)
[42101-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.ddl.CreateTable.update(CreateTable.java:108)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:209)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:178)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:153)
at play.db.Evolutions.execute(Evolutions.java:451)
at play.db.Evolutions.listDatabaseEvolutions(Evolutions.java:404)
at play.db.Evolutions.getEvolutionScript(Evolutions.java:330)
at play.db.Evolutions.checkEvolutionsState(Evolutions.java:297)
at play.db.Evolutions.main(Evolutions.java:76)
~ Application revision is 1 [229648e] and Database revision is 0
[da39a3e]
~
15:04:59,729 ERROR ~
org.h2.jdbc.JdbcSQLException: Tabulka "PLAY_EVOLUTIONS" již existuje
Table "PLAY_EVOLUTIONS" already exists; SQL statement:
create table play_evolutions (id int not null primary key, hash
varchar(255) not null, applied_at timestamp not null, apply_script
text, revert_script text, state varchar(255), last_problem text)
[42101-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.ddl.CreateTable.update(CreateTable.java:108)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:209)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:178)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:153)
at play.db.Evolutions.execute(Evolutions.java:451)
at play.db.Evolutions.listDatabaseEvolutions(Evolutions.java:404)
at play.db.Evolutions.getEvolutionScript(Evolutions.java:330)
at play.db.Evolutions.main(Evolutions.java:101)
15:04:59,748 ERROR ~
org.h2.jdbc.JdbcSQLException: Tabulka "PLAY_EVOLUTIONS" již existuje
Table "PLAY_EVOLUTIONS" already exists; SQL statement:
create table play_evolutions (id int not null primary key, hash
varchar(255) not null, applied_at timestamp not null, apply_script
text, revert_script text, state varchar(255), last_problem text)
[42101-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.ddl.CreateTable.update(CreateTable.java:108)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:209)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:178)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:153)
at play.db.Evolutions.execute(Evolutions.java:451)
at play.db.Evolutions.listDatabaseEvolutions(Evolutions.java:404)
at play.db.Evolutions.getEvolutionScript(Evolutions.java:330)
at play.db.Evolutions.applyScript(Evolutions.java:221)
at play.db.Evolutions.main(Evolutions.java:130)
15:04:59,807 ERROR ~
org.h2.jdbc.JdbcSQLException: Nedodržení unikátního indexu nebo
primárního klíče: "PRIMARY KEY ON PUBLIC.PLAY_EVOLUTIONS(ID)"
Unique index or primary key violation: "PRIMARY KEY ON
PUBLIC.PLAY_EVOLUTIONS(ID)"; SQL statement:
insert into play_evolutions values(?, ?, ?, ?, ?, ?, ?) [23001-149]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:
327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at
org.h2.index.PageDataIndex.getNewDuplicateKeyException(PageDataIndex.java:
152)
at org.h2.index.PageDataIndex.add(PageDataIndex.java:130)
at org.h2.table.RegularTable.addRow(RegularTable.java:125)
at org.h2.command.dml.Insert.insertRows(Insert.java:126)
at org.h2.command.dml.Insert.update(Insert.java:86)
at org.h2.command.CommandContainer.update(CommandContainer.java:69)
at org.h2.command.Command.executeUpdate(Command.java:209)
at
org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:
181)
at play.db.Evolutions.applyScript(Evolutions.java:234)
at play.db.Evolutions.main(Evolutions.java:130)
~ Can't apply evolutions...

v6ak

unread,
May 4, 2011, 3:53:07 PM5/4/11
to play-framework
Adding ";MODE=MYSQL" to the URL has solved the problem.

The excerpt of application.conf looks like this:
db.url=jdbc:h2:/some/path/to/your/database;MODE=MYSQL
db.driver=org.h2.Driver
db.user=sa
db.pass=
Reply all
Reply to author
Forward
0 new messages