Reputation: 135
I created a table using Mapper in Scala.
class Stage extends Mapper[Stage]
{
def getSingleton = Stage
object controlId extends MappedLongForeignKey (this,Control) {
override def dbNotNull_? = true
override def dbColumnName = "control_id"
}
}
but my table does not create a constraint for the foreignKey key in database.
Upvotes: 3
Views: 440
Reputation: 24032
Lift, like Rails, does not create foreign key constraints by default. If you want to enable them, you can do so via MapperRules
. Put this in your Boot
somewhere before you do other database initialization stuff.
MapperRules.createForeignKeys_? = (_) => true
The var createForeignKeys_?
is a function of type ConnectionIdentifier => Boolean
. I suppose this allows you to control foreign key creation per-connection, but most applications only have a single database connection.
Upvotes: 7