Reputation: 1931
I am using play framework and wondering a problem in evolutions. After I changed my models (e.g. add a field), I prepare proper sql script (both for UPs and DOWNs) e.g. 3.sql (assuming I have already 2 evolution scripts) and put in related folder.
But the play shows me this message:
Database 'default' needs evolution!
# !!! WARNING! This script contains DOWNS evolutions that are likely destructive
# --- Rev:2,Downs - 3ee3d8e
ALTER TABLE my_table DROP COLUMN low_priority;
# --- Rev:1,Downs - 4f92dc6
[ a long script which drops all tables!]
# --- Rev:1,Ups - 5501951
[ a long script creating tables ] # --- Rev:2,Ups - 3ee3d8e
ALTER TABLE my_tableADD COLUMN low_priority tinyint(1) default 0 not null;
# --- Rev:3,Ups - 397ada5 ALTER TABLE my_table CHANGE COLUMN low_priority lowpriority TINYINT(1) NOT NULL DEFAULT '0' ;
Why play (and actually its ORM : EBean) behaves this way? It should just run "UPs" of 3.sql (last evolution script) and not roll back through history!
P.S. I am speaking about my dev instance (As the above is not happening in PROD). But for some reasons I must have some heavy data in my dev DB and doing a "backup&restore" each time really takes time.
Upvotes: 1
Views: 445
Reputation: 1931
I founded why this happens. According to this link:
In play 2.2 different evolutions are checked from first to last: first 1.sql is checked against evolution 1 in db, then 2, 3 and so on. If some pair differs, all evolutions sgarting from different will need to be downgraded and upgraded. In previous versions of play evolutions were checked from last to first-equal, so if your last evolutions were equal, other evolutions were not checked.
After this two changes play finds first evolutions with different whitespace and asks to reapply them.
Upvotes: 0