DorianOlympia
DorianOlympia

Reputation: 851

Play framework ignores evolution script

I'm currently covering the basics of SQL databases and using them in play framework. I have created postgres database and successfully configured it in my application.conf

db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://database.example.com/playdb"
db.default.user=postgres
db.default.password=qwerty

I have also created 1.sql file in conf/evolutions/evolutions/default directory and wrote there same example SQL code to create simple table. The problem is that play seems to ignore the existence of this file. When I run my server and connect to localhost, I'm suppoused to be asked by Play, whether I would like to have my script applied to my database or not. Unfortunately I'm not and the only thing play is doing, is loading my home page (CREATE TABLE in 1.sql is not executed and I don't have any tables created). Any ideas what am I doing wrong?

Upvotes: 2

Views: 979

Answers (2)

udidav
udidav

Reputation: 1

In my case, evolution ignored 2.sql (and 1.sql).

To resolve this I had to remove those comments from 1.sql:

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

and add my own comment such as:

# Initial version

Also, viewing 1.sql file in VI revealed it contains ^M characters which had to be removed.

After those two steps, evolution stopped overwriting 1.sql and finally used the provided 2.sql file.

Evolution seems to overwrite 1.sql even if you do not perform the db update, so make sure you are editing the original version.

I am using play 2.4.1.

Upvotes: 0

Ryuu
Ryuu

Reputation: 606

Make sure you have following line in your build.sbt file

libraryDependencies += evolutions

Upvotes: 2

Related Questions