Play framework - problem with creating a database

I work with Play! 1.2.4, and I ran into a curious problem.

As far as I know, if I installed jpa.ddl in my configuration to create-drop, it should delete my tables, reload and restart the application.

jpa.ddl=create-drop 

Do I think that it will only fall and create tables related to the modified models? I have a problem when I have a model that has changed, but it does not drop the table. I tried to reset the table manually, but this will not allow, because it Cannot delete or update a parent row: a foreign key constraint fails . I understand this problem and fix it, I can manually delete the entire table and restart the application so that it collects tables from scratch.

My question is, what is the problem that is playing! is there why it does not update this table, and if there is a way to get around this through the configuration files, and not manually drop my table?

Thanks.

EDIT

Just for more information, I just assume that this is a problem, and it may be something completely different, but here is what I get in my magazines:

 Unsuccessful: create table Product Table 'Product' already exists 

I also just understood the changes taking place at this load. I used to have such a relationship

 Product *-* Image 

This is the ManyToMany relationship between the Product and Image table. The table "Image" is now gone, and the relationship will disappear. However, it seems to me that the image table is not deleted, but the Product is trying to delete and rebuild. This may cause a foreign key constraint problem. Why not play this table if its model no longer exists?

+4
source share
2 answers

Performing playback in dev mode? But why aren't you using jpa.ddl = update?

0
source

Auto modifying a circuit using jpa is actually not the best way to do it. Play provides an evolution mechanism that is more reliable because you indicate what changes.

In the example below, if you delete a model class such as Image, JPA knows nothing more about the Image class, so it will not delete the Image table and the Product_Image table of products. Therefore, it cannot delete the Product table. JPA does not have any knowledge of what was in the database before changing its model.

Evolutions are a little more tedious to use at startup because you create evolution files manually, but with this mechanism your database structure is exactly what you want

0
source

Source: https://habr.com/ru/post/1414102/


All Articles