Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework 2.4.3 evolutions not triggered

I'm doing the todo tutorial of Play. When I created the evolution in conf/evolutions/default/1.sql nothing happens. I just get the Exception JdbcSQLException: Table "TASK" not found which makes sense.

I applied the evolution manually to the DB with h2-browser in activator console and after that it works. But the evolutions don't show up automatically.

application.conf

# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
#
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
db.default.username=sa
db.default.password=""

# New
evolutionplugin=enabled
applyEvolutions.db=true
applyEvolutions.default=true
applyDownEvolutions.default=true

# Evolutions
# ~~~~~
# You can disable evolutions if needed
# play.evolutions.enabled=false

# You can disable evolutions for a specific datasource if necessary
# play.evolutions.db.default.enabled=false

1.sql

# Tasks schema

# --- !Ups

CREATE SEQUENCE task_id_seq;
CREATE TABLE task (
    id integer NOT NULL DEFAULT nextval('task_id_seq'),
    label varchar(255)
);

# --- !Downs

DROP TABLE task;
DROP SEQUENCE task_id_seq;
like image 381
fdelia Avatar asked Jan 31 '26 01:01

fdelia


2 Answers

Ok. I read the migration docs and one has to apply libraryDependencies += evolutions to build.sbt.

Then it works like expected.

These are not necessary, they will apply the evolution automatically (without showing the Database 'default' needs evolution!):

applyEvolutions.db=true
applyEvolutions.default=true
applyDownEvolutions.default=true
like image 95
fdelia Avatar answered Feb 02 '26 13:02

fdelia


Just an update for Play 2:

play.evolutions.enabled = true
play.evolutions.autoApply=true
play.evolutions.autoApplyDowns=true
like image 26
pik4 Avatar answered Feb 02 '26 15:02

pik4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!