Tested on ActiveRecord 5.x, 6.x.
Add this line to your application's Gemfile:
gem 'pg_inheritance' And then execute:
$ bundle install Or install with:
$ gem install pg_inheritance In your migration declare iherited_from option for create_table method call:
class CreateMembers < ActiveRecord::Migration def change create_table :users do |t| t.string :name end create_table :members, inherits: :users do |t| t.string :logo_url end end endAfter migrations members has available both columns.
In your migration call drop_inheritance method.
class DropMemberUsersInheritance < ActiveRecord::Migration def change drop_inheritance :members, :users end end- with_columns - if
truethen inherited columns will be dropped.
If inheritance has not exists it raises an exception.