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

Feature Request: Disable Spring Boot auto config if migration not enabled #1171

Closed
Dimibe opened this issue Dec 20, 2023 · 5 comments
Closed

Comments

@Dimibe
Copy link

Dimibe commented Dec 20, 2023

Hello,
I came across the issue that even if with org.neo4j.migrations.enabled=false the Spring Boot auto config will load at startup.
This is normally not an issue since the migration itself does not run. But in some cases, an unexpected behavior can occur.

E.g. at startup the method neo4jMigrationsConfig will be called, which can lead to an exception here if the other migrations properties are not well-defined.

In contrast this bean for example will only load if the migrations are enabled. So I wonder if we can apply the condition on class level or at least prevent the possible exception if migrations are disabled?

@michael-simons
Copy link
Owner

Hi,

thanks for raising this. If there's no config, I cannot give you to Migrations bean at all.

The only exception that can be thrown from the other method should be if the migrations are - as you write - not in place.

Doesn't help setting org.neo4j.migrations.check-location to false then?

Btw I see you are located in Aachen (I am too)? Are you able to share about your use case?

@Dimibe
Copy link
Author

Dimibe commented Dec 22, 2023

Hi,
thanks for your feedback.
Yes, setting org.neo4j.migrations.check-location to false helped. I just wondered because I thought disabling the migrations would prevent any configuration on startup.

Yes you're right, I'm also located in Aachen. Seems to be a small world :D
My use case is that I use the migrations only for development through Spring Boot. Elsewhere I use the binary inside my deployment process as you already suggested to my in this comment.

Since I use Testcontainers at development time I just came to the conclusion that I could change the migrations dependency to test scope. This way it's still usable during development and completely excluded in production builds.

@michael-simons
Copy link
Owner

Sorry for getting back late to you.
So, I first thought you only want to disable validation, now I understand you don't want the migration itself.

You can set

org.neo4j.migrations.enabled = false

in your Spring Boot config: That will disable Neo4j-Migrations on startup, but will still give you both a ac.simons.neo4j.migrations.core.Migrations and a ac.simons.neo4j.migrations.core.MigrationsConfig bean with which you can interact if needed.

If this helps, please close the ticket :)

Eitherway, kind regards and all the best for 2024.

@Dimibe
Copy link
Author

Dimibe commented Dec 31, 2023

Hi and thanks,

yes, your answer helped me. Seems that I missed the use case of having the migration beans available while the migration itself disabled. I will close the ticket. :)

Wishing you a Happy New Year!

@Dimibe Dimibe closed this as completed Dec 31, 2023
@michael-simons
Copy link
Owner

Thank you, Dimitrios and same to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants