strongtyped/active-slick — pull request #9 by ElessarWebb (2014-07-24 10:51:33+00:00)
Title: Boilerplate for app that installs database fixtures

Hi,

This PR is meant to check if you're interested in incorporating these kind of extensions of active-slick.
I have no idea what vision you have for the project, so shoot it down if you don't want it.

This PR introduces a lightweight typeclass for classes that act as the data models, such that you can abstract over any of those classes easily, e.g.:

```Scala
/**
* Basic trait for database fixtures
*/
abstract class Fixture[U : Model](val objects: Seq[U]) {
val model = implicitly[Model[U]]

def install()(implicit session: Session) = model.query.insertAll(objects : _*)
}
```

This only works on classes that have a corresponsing `Model[U]` instance.

Furthermore, it adds the necessary boilerplate for setting up a main class that allows you to (selectively) install database fixtures.

```Scala
object Fixture extends App
with Fixtures
with FixtureApp
with UserFixture
with BlogFixture {

lazy val fixtures: Seq[Fixture[_]] = List(
UserFixture,
BlogFixture
)

main()
}

trait UserFixture { this: ActiveSlick with Auth with Fixtures =>
object UserFixture extends Fixture(
List(
User(None, "some", "some@user.nl", "hashedandsaltedpassword", "salt!"),
)
)
}
```