michael-simons / neo4j-migrations

Automated script runner aka "Migrations" for Neo4j. Inspired by Flyway.
https://michael-simons.github.io/neo4j-migrations/
Apache License 2.0
113 stars 22 forks source link

Add support for spring bean injection using java-based migrations #1393

Closed rugbroed closed 1 month ago

rugbroed commented 1 month ago

neo4jmigrations is supporting java-based migrations, however, not using spring bean injection.

I would like to see something like this;

public class V0_0_1__MyPojoMigration implements JavaBasedMigration {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private MyNeo4jRepository myNeo4jRepository;

    @Override
    public void apply(MigrationContext context) {
        List<MyPojo> myPojos = myNeo4jRepository.findAll();

        ...
    }
}

Thanks for a great project!

michael-simons commented 1 month ago

@all-contributors please add @rugbroed for ideas

allcontributors[bot] commented 1 month ago

@michael-simons

I've put up a pull request to add @rugbroed! :tada:

michael-simons commented 1 month ago

Thanks for the cool idea.

To benefit from this in 2.11.0 you'll need to opt in by annotating the migrations in questions with a stereotype such as @Component.

You can do this on a case by case basis, other migrations will still be loaded, and components have precedence.