lastland / migrations

0 stars 0 forks source link

Sequential compilation of migrations in SBT #6

Open cvogt opened 9 years ago

cvogt commented 9 years ago

Hi @jsureth @eed3si9n @gzm0 @sjrd /cc @dotta,

this is a GSOC project working on a new database migration tool allowing type-safe migrations on top of Slick among other things. We try to do something unusual with SBT, i.e. compiling and running lots of files in sequence. Maybe you guys could give us some input on what's possible and how.

Migrations can refer to columns or other schema elements introduced by earlier migrations. Migrations being type-safe means that type needs to exist when referring to things. Slick has a code generator that can create types for an existing schema, but if an earlier migration hasn't been applied yet, slick can't generate code, which means the later migrations can't be compiled. So what needs to happen is that earlier migrations are compiled and run before later migrations are compiled and run.

Any ideas?

Chris

eed3si9n commented 9 years ago

sbt 0.13.8 adds sequential tasks. Not sure if this could help but worth a shot - http://www.scala-sbt.org/0.13/docs/sbt-0.13-Tech-Previews.html#Sequential+tasks

/cc @jsuereth

cvogt commented 9 years ago

I guess we'd have to find all migration file during build file run time and dynamically create tasks for each of them. Does that sound practical?

lastland commented 9 years ago

Hi, thanks for the comments! But I'm still not sure how to make use of this feature.

In our case, an earlier migration is not only required to be compiled before the compilation of a later migration, but also to be run (so the migrations can be applied to the database, and the new code for new schemas (which a later migration file might depend on) will be generated) before the compilation of a later migration.