New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@OnDelete is ignored #145
Comments
3 years without a resolution... any chance to get this fixed? @dkunzler , did you figure out a workaround? |
Hey, @szczebel as far as I remember I had at least seen some interesting behaviour about this one. I will have a look at this project and let you know what I've found out within the next few days! |
@dkunzler, imagine I'm dregding up the past I'd be keen if you did find anything for this. |
Hi @stefpiatek sorry I forgot in january. I created a gist with our code: strangely the two classes I added in the gist are not used or configured anywhere, I guess that they are picked up automatically by liquibase since they reside in the liquibase package. With this code I was able to generate the onDelete action on foreign key constraints. However this will not pick up a deleted Since this project is rather old the version used here is 'org.liquibase.ext:liquibase-hibernate5:3.6' Perhaps that will help you. You can also comment on the gist if you have questions |
That's great, thanks for the gist, handy to see that it'll get picked up and adding it in isn't too much work. Because it's an intentional decision not to include any FK properties, I wonder whether a PR to add in on delete functionality alone (say turned on in the liquibase.properties) would be accepted? |
In case others find it useful, here's our implementation and testing for generating changelogs with @onDelete that can be run as a maven goal https://github.com/inform-health-informatics/liquibase-hibernate-fk-on-delete |
Hi" If this could be converted to a PR I can review and merge it... if there is still interest in this improvement ;) |
Ah yeah I've been putting this off as my changes have gotten stale. I'll see if I get some time set aside to update and make a PR |
Consider the following class (shortened from the original, Tenant is another class):
`
@entity
public class User {
@id
Long id;
}
`
This should make a foreignkey constraint with onDelete="CASCADE" in liquibase. But this isn't the case.
There is just a normal FK constraint without an onDelete.
Therefore deleting a tenant will fail if there are users left. If I let hibernate itself generate the database (even with the same dialect used in liquibase-hibernate) the constraint is generated and the user gets deleted when tenant is deleted. (confirmed by local unit test)
Do you have any advisory for this case other than adding the onDelete action by hand?
Regards
David
┆Issue is synchronized with this Jira Bug by Unito
The text was updated successfully, but these errors were encountered: