Skip to content
This repository was archived by the owner on Sep 9, 2021. It is now read-only.

sigmen/pg_inheritance

Repository files navigation

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.

About

Implementing PostgreSQL Table Inheritance

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published