Sharing methods among migrations?


I’m using migrations in my app (why wouldn’t you?) but using the execute
method so that I can layer in check constraints/foreign keys and some
postgres-specific data integrity niceties. Anyway:

Say I want to share methods among migrations, for instance to centralize
column definitions. I have about 15 or so columns in multiple tables
that will be defined with the same check constraints and type, the only
difference being the name.

I guess I’m looking to create helper methods to share amongst all my
migrations. Thoughts?

I’d imagine I’d create a class that has ActiveRecord::Migration as a
parent, and then put the methods in there and have my migrations inherit
from that. Where would I put this new class?


Forget it.

AWDwR has a pretty good intro to migration helpers, and

will give you the basics, too.


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