Stable Rails application in production using Oracle db causes replication failures due to sequence

My installation replicates my backend Oracle db across multiple servers. There have been chronic replication failures because Rails won’t let Oracle manage sequences with its own triggers. The proposed solution is to add self.set_sequence_name = :autogenerated to my models. It doesn’t seem very DRY to edit all 30+ of my database table models with this statement. I would prefer some solution like an oracle.rb initialization file, or maybe some mechanism in the module I use to extend ActiveRecord::Base that my models extend.
Please know that RoR is not my first language, as a result my head is spinning as I try to evaluate possible strategies. I just know I need to adjust Rails behavior to allow Oracle to manage its own sequences and triggers.
My application is built on RoR 5.2 and my Oracle version is 11g.

It sounds to me you can add that line to ApplicationRecord class. I think a Rails project has this by default. Then all your model will inherit it.

class ApplicationRecord < ActiveRecord::Base
  self.set_sequence_name = :autogenerated
end

class YourModel < ApplicationRecord
end

class AnotherModel < ApplicationRecord
end

This forum is for general Ruby, so you might get better answers on one of Ruby on Rails forums.

Thank you for your advice. It is so difficult to find help for specific scenarios like this.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs