# PostgreSQL Table inheritance in Rails?

**URL:** <https://www.ruby-forum.com/t/postgresql-table-inheritance-in-rails/120248>\
**Category:** Rails\
**Created:** [November 15, 2007, 4:57am UTC](https://www.ruby-forum.com/t/postgresql-table-inheritance-in-rails/120248 "2007-11-15T04:57:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chirag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ecccb3/32.png) [@chirag](https://www.ruby-forum.com/u/chirag)\
**Post date:** [November 15, 2007, 4:57am UTC](https://www.ruby-forum.com/t/postgresql-table-inheritance-in-rails/120248/1 "2007-11-15T04:57:19Z")

</div>

Does anyone know how I can use PostgreSQL inheritance (see below) in a  
Rails migration? I don’t mean single table inheritance supported in  
Rails with the ‘type’ attribute

Thanks,  
Chirag

> **[5.10. Inheritance](https://www.postgresql.org/docs/8.1/ddl-inherit.html)**
>
> 5.10. Inheritance 5.10.1. Caveats PostgreSQL implements table inheritance, which can be a useful tool for database designers. (SQL:1999 and later define …

CREATE TABLE cities (  
name text,  
population float,  
altitude int – in feet  
);

CREATE TABLE capitals (  
state char(2)  
) INHERITS (cities);

In this case, the capitals table inherits all the columns of its  
parent table, cities. State capitals also have an extra column, state,  
that shows their state.
