yogthos / migratus

MIGRATE ALL THE THINGS!
647 stars 95 forks source link

Filesystem lookup and complementary operation to pending migrations. #163

Closed katox closed 5 years ago

katox commented 5 years ago

As suggested in #162 I cut out the application code and created a repository for native Standalone Migration Runner (currently limited to PostgreSQL).

See PGMig repo. If you have a PostgreSQL server running you can give it a go. It's a first draft but it should work.

Native-image means to resource lookup are inherently much more limited than in plain java. For a standalone tool it meant that find-migration-dir needed to be enhanced to allow filesystem access.

The first patch enables the FS lookup in a backward compatible way.

To better support the runner (which is harder to debug than a java app) I added more detailed output and a list operation support code in Migratus (the second patch).

yogthos commented 5 years ago

Thanks, that's fantastic work, and the PR looks great! I might have a use for PGMig myself for running migrations from the build server.

yogthos commented 5 years ago

The lein-native-image plugin might be worth looking at as well for generating the executable via lein. And I'd add a note about create-image.sh in the readme for building an executable locally.

katox commented 5 years ago

It's a good idea to mention the create-image.sh script if someone wanted to build it locally with Graal already installed.

I'm not sure about the lein-native-image plugin because the build can get more involved as features grow and lein plugins aren't very flexible. Especially when one gets to features that are implemented via JNI and native shared libraries in the JDK itself (like security). You need to copy those .so files to the target system and point there the java.library.path when running the resulting native binary.

yogthos commented 5 years ago

Yeah I think you're right, and running a script isn't exactly difficult. I got it to build locally, and works great. I also just pushed out 1.2.2 to Clojars.