I have the following BootStrap.scala class in my project that I'm using to load default data:
class BootStrap extends Job {
override def doJob() {
import models._
import play.test._
// Import initial data if the database is empty
if (Athlete.count().single() == 0) {
Yaml[List[Any]]("initial-data.yml").foreach {
_ match {
case a: Athlete => Athlete.create(a)
case w: Workout => Workout.create(w)
case c: Comment => Comment.create(c)
}
}
}
}
}
For some reason, only my "athlete" table is getting populated and the others aren't. I tried turning on debugging and trace, but nothing shows up in the logs.
This was working fine when connecting to "db=mem", but since I've changed to PostgreSQL, this behavior is happening. Below is my initial-data.yml:
- !!models.Athlete
id: !!Id[Long] 1
email: mra...@gmail.com
password: beer
firstName: Matt
lastName: Raible
- !!models.Athlete
id: !!Id[Long] 2
email: trishm...@gmail.com
password: whiskey
firstName: Trish
lastName: McGinity
- !!models.Workout
id: !!Id[Long] 1
title: Chainsaw Trail
distance: 7
duration: 90
athlete_id: 1
postedAt: 2011-10-13
description: >
A beautiful fall ride: cool breezes, awesome views and yellow leaves.
Would do it again in a heartbeat.
- !!models.Workout
id: !!Id[Long] 2
title: Monarch Lake Trail
distance: 4
duration: 90
athlete_id: 1
postedAt: 2011-10-15
description: >
A beautiful afternoon of hiking with fishing along the way.
- !!models.Workout
id: !!Id[Long] 3
title: Creekside to Flume to Chainsaw
distance: 12
duration: 150
athlete_id: 2
postedAt: 2011-10-16
description: >
Awesome morning ride through falling yellow leaves and cool fall breezes.
- !!models.Comment
id: !!NotAssigned
author: Jim
content: >
Nice day for it!
postedAt: 2011-10-16
workout_id: 1
- !!models.Comment
id: !!NotAssigned
author: Joe
content: >
Love that trail.
postedAt: 2011-10-15
workout_id: 2
Figured it out. In dependencies.yml:
- upgrades -> scala 0.9.1-20111025
repositories:
- upgrades:
type: http
artifact: "http://static.raibledesigns.com/[module]-[revision].zip"
contains:
- upgrades -> *
Still interested in an answer to the following question...