Skip to content
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

@NotNull should also apply to DDL #1702

Open
Tracked by #107
jo-elimu opened this issue Jul 11, 2024 · 3 comments
Open
Tracked by #107

@NotNull should also apply to DDL #1702

jo-elimu opened this issue Jul 11, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jo-elimu
Copy link
Member

jo-elimu commented Jul 11, 2024

The JPA schema export at https://github.com/elimu-ai/webapp/blob/main/src/main/resources/META-INF/jpa-schema-export.sql should apply not null when an entity's property is annotated with @NotNull.

https://stackoverflow.com/questions/51258073/notnull-annotation-does-not-translate-to-not-null-constraint-in-schema-generati

Make changes so that @NotNull automatically adds not null to the database layer (DDL + production database).


Relates to #1286, #1607

@jo-elimu jo-elimu added the bug Something isn't working label Jul 11, 2024
@venkatesh2k3
Copy link
Contributor

venkatesh2k3 commented Jul 12, 2024

@jo-elimu So, do we need to add null constraints to the model classes according to this file https://github.com/elimu-ai/webapp/blob/main/src/main/resources/META-INF/jpa-schema-export.sql

@jo-elimu
Copy link
Member Author

jo-elimu commented Jul 12, 2024

@jo-elimu So, do we need to add null constraints to the model classes according to this file https://github.com/elimu-ai/webapp/blob/main/src/main/resources/META-INF/jpa-schema-export.sql

@venkatesh2k3 No, because we want not null to be applied implicitly to the DDL whenever a property is annotated with @NotNull, which they are in many classes already.

I don't know when and why this stopped working, but I suspect it has to do with the dependency versions we use. We also made the switch from MySQL to MariaDB a few years ago, so maybe we should replace the usage of MySQL in our DB configuration as well.

We are currently running MariaDB 11.4.2 in production: https://github.com/elimu-ai/webapp/blob/main/src/main/config/DEPLOY.md

@jo-elimu
Copy link
Member Author

Possibly related: https://stackoverflow.com/a/51734560

@jo-elimu jo-elimu changed the title @NotNull should apply to DDL @NotNull should also apply to DDL Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants