Project

pg_schema

0.0
No commit activity in last 3 years
No release in over 3 years
Support for postgres schemas
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Features

  • Automatically sets fully qualified table_name for all models
  • Adds a schema aware db:create_with_schema rake task

Installation

Add the gem to your gemfile

gem 'pg_schema'

Run install generator

rails g pg_schema:install

Add a schema search path to your database.yml

...
host: localhost
database: my_project_dev
schema_search_path: my_schema
...

Create db and schema

rake db:create_with_schema

Test in console

>> Model.table_name
>> "my_schema.models"

Issues

  • Running pg_schema:install with schema_search_path already set may break if the database exists but the specified schema doesn't. Remove the schema_search_path from your database.yml, run pg_schema:install, then add the search path back before running db:create_with_schema.