Question

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

Was it helpful?

Solution 2

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.

OTHER TIPS

I'm guessing that your issue is with Schema generation, not with querying the database. If that's the case, then you probably just want to avoid having Squeryl create the tables directly. Squeryl's schema generation is purposefully basic. When you outgrow what it can do I think you're better off adopting some method that gives you greater control than a "read your model and generate stuff" tool can offer. Tools like Flyway or Liquibase are good for this.

If you don't want to adopt a new library you can also use Squeryl to output the schema to a file through one of the Schema.printDdl methods then remove the extraneous sequence before executing it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top