lastland / scala-forklift

Type-safe data migration tool for Slick, Git and beyond.
Other
188 stars 31 forks source link

Provide SQL migration via SQL file #39

Closed sdether closed 6 years ago

sdether commented 6 years ago

I would like to use my SQL files that I have syntax checking on for plain SQL migrations rather than embedding them in sqlu interpolation.

This may already be possible, but I could not figure out how to turn a file resources into a SqlAction, and could not find a better venue than issues to pose this questions.

lastland commented 6 years ago

Hi @sdether,

Thanks for bringing this up here! This is not supported by Forklift right now but sounds like a good feature to be added! I am marking this issue and will try to add this as soon as I have more time on this (unfortunately I'm currently occupied by other obligations)!

sdether commented 6 years ago

@lastland I was trying to google around to see if there is a way create an SqlAction from a string at runtime and couldn't find anything. If you know of a way or have some pointer to the area of slick that should make it possible, I'd love to work on a pull request to add this.

lastland commented 6 years ago

I am not sure, either.

One resource might be helpful here is: https://github.com/slick/slick/blob/39abcda1fed2f6051e8c0202ec72de37c07314d9/slick-testkit/src/main/scala/com/typesafe/slick/testkit/util/TestCodeGenerator.scala#L61

If I have understood correctly, this piece of code just reads lines from a sql file (initScript) and put them inside sqlu.

I don't know if there is a better way to do that in Slick.

@cvogt @trevorsibanda Can you help us here?

sdether commented 6 years ago

Didn't even think of just using interpolation a la sqlu"#$sql" for this. Ok, I'll work on a SQL script migration addition for forklift via this path. Thanks!

lastland commented 6 years ago

Resolved by #41