Search code examples
postgresqlscalaormsqueryl

How can i use one sequence to auto increment several tables in squeryl (PostgreSQL)?


I have follows

val s1 = autoIncremented("advert_id_seq")
on(car)(attributes => declare(attributes.id is (s1)))
on(danceInstructor)(attributes => declare(attributes.id is (s1)))

When i run my app a catch following exception

org.postgresql.util.PSQLException: ERROR: relation "advert_id_seq" already exists

As i realized, squeryl try to create sequence twice and gets error


Solution

  • Ruby on Rails has a polymorphic association, but scala active record don't have its. I made something like it's, and will push it in github repo.