0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Gem implements multitable iheritance.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.17
~> 12.3.3
~> 3.0
 Project Readme

PG Inheritance

Gem Version Build Status

UNDER DEVELOPMENT

Supports

Tested on ActiveRecord 5.x, 6.x.

Installation

Add this line to your application's Gemfile:

gem 'pg_inheritance'

And then execute:

$ bundle install

Or install with:

$ gem install pg_inheritance

Migrations

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
end

After migrations members has available both columns.

Drop inheritance

In your migration call drop_inheritance method.

class DropMemberUsersInheritance < ActiveRecord::Migration
  def change
    drop_inheritance :members, :users
  end
end

Options

  • with_columns - if true then inherited columns will be dropped.

If inheritance has not exists it raises an exception.