2

I thought I had the solution here: application-wide sequence It looks like behaviour has changed since Rails 5.

I define a specific sequence to handle my objects ids:

class BusinessRule < ActiveRecord::Base

### id generation
  self.sequence_name = "objects_seq"

The migration, (which ran before I edit the model), generated a sequence for Business Rules:

business_rules_id_seq

And this sequence is referenced in the COLUMN_DEF attribute of the business_rules.id column.

Despite the self.sequence_name directive, ActiveRecord still uses the conventional sequence business_rules_id_seq. Deleting the sequence does not change a thing.

Can you help ?

Community
  • 1
  • 1
user1185081
  • 1,898
  • 2
  • 21
  • 46

1 Answers1

0

I interpret "The migration, (which ran before I edit the model)" as the following:

  1. You ran migrations to create the table
  2. You then updated the model with the sequence_name

If this is correct, I suspect that you need to either

  1. Have to add the sequence in the model before migrations, or
  2. Look at this question for explicitly setting sequences on migrations
Community
  • 1
  • 1
ekampp
  • 1,904
  • 18
  • 31