virtuslab / play-slick-configuration

Type-safe way to maintain configuration tables in Play using Slick


Configuration table for Slick and Play

Build Status

It's a small helper library based on Slick and play-slick plugin from Play! framework. It provides nice type-safe way to serialize properties of custom types to database and then read them back.



Feel free to use it, test it and to contribute!

Getting play-slick-configuration

Library is available in sonatype and Maven central since version 1.1.0.

libraryDependencies += "org.virtuslab" %% "play-slick-configuration" % "1.2.0"

This branch is built against Slick 2.1.x, for Slick 1.x use slick-1.0 branch.



To use this library you need to create a configuration table in database with a key and value text fields.

Easiest way to do this is just by running:

import org.virtuslab.config.ConfigurationEntries
import play.api.db.slick.Config.driver.simple._


Or adding following SQL (it's from PostgreSQL, syntax may vary) to your setup or evolution scripts:

CREATE TABLE configuration
  key character varying(254) NOT NULL,
  value character varying(254) NOT NULL,
  CONSTRAINT configuration_pkey PRIMARY KEY (key)




Serialization and de-serialization of properties are based on a type-class called ConfigurationSerializer:

trait ConfigurationSerializer[A] {
  def write(a: A): String

  def read(s: String): A

This library comes with instances of this type-class for several types, but you can easily create your own instances of it by placing an implicit val (or def or object) in scope.