简体   繁体   中英

Is it possible / safe to skip evolutions in Play Framework

I unfortunately built and installed a new production database with Play evolutions disabled, but now I am needing to make some changes to the database structure and have just realised that I cannot apply the evolutions as I get "inconsistent state" warnings when the evolution script tries to create the already existing tables.

I'm now wondering, would it be possible to remove 1.sql (containing all the table generation) and just leave in 2.sql (which contains various AMEND TABLE) instructions.

My initial thought is definitely not , but I can't think of a better way than by having to stop the production server to dump / re-insert after applying evolutions.

If I understand your problem correctly, you could use various approaches.

  • A less elegant one is just to modify the evolution table on the database. This table is named as play_evolutions . Going to set the state in "applied" for the entries that you do not want to be executed. In this way when evolutions starts it will not execute the queries with this wording.

  • Another approach is to perform checks in the new queries you are going to create, that is to create queries that go to check which tables are already there and avoid creating inconsistencies. However, this presupposes writing a stored procedure inside the SQL file.

If you want more details, report a use case so that we can understand together which is the best way

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM