Slick 2.0 Creating Check Constraints

308 views Asked by At

How can I represent the following check constraint in Slick mapping definitions?

CREATE TABLE mySchema.myTable
(
  id character varying(255) NOT NULL,
  name text NOT NULL,
  active boolean NOT NULL,
  CONSTRAINT pkey PRIMARY KEY (id, name),
  CONSTRAINT check_valid_name check (name in ('Name1', 'Name2'))
);

How can I use the check_valid_name in my Slick table definitions in Scala?

1

There are 1 answers

0
Biswanath On BEST ANSWER

I don't think there exist any way of doing thing through table definitions. If you want to achieve this through slick you can use staticquery to define your constraint.