How to define the sequence to use when creating a table in ActiveRecord migration in Ruby on Rails 5.2?
问题 I need to assign a specific Postgres sequence to the ID field of my table. In the model, I tried to define the following setup which has no effect on Posgres: class MyObject < ActiveRecord::Base self.sequence_name = "global_seq" Usually, a table definition in ActiveRecord migrations start with create_table "objects", id: :serial, force: :cascade do |t| which generates a Postgres definition of column default value as default nextval('objects_id_seq'::regclass) How can I specify in the