From 1fdbe95fe1e9318c264ff49bb3b79e2c82b6a6ee Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Sat, 30 Jan 2016 11:20:15 -0600 Subject: [PATCH] Add Set Schema Search Path as a rails til --- README.md | 1 + rails/set-schema-search-path.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 rails/set-schema-search-path.md diff --git a/README.md b/README.md index 1afd820..02d2f85 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,7 @@ _310 TILs and counting..._ - [Retrieve An Object If It Exists](rails/retrieve-an-object-if-it-exists.md) - [Select A Select By Selector](rails/select-a-select-by-selector.md) - [Select Value For SQL Counts](rails/select-value-for-sql-counts.md) +- [Set Schema Search Path](rails/set-schema-search-path.md) - [Show Pending Migrations](rails/show-pending-migrations.md) - [Show Rails Models With Pry](rails/show-rails-models-with-pry.md) - [Show Rails Routes With Pry](rails/show-rails-routes-with-pry.md) diff --git a/rails/set-schema-search-path.md b/rails/set-schema-search-path.md new file mode 100644 index 0000000..37eaa12 --- /dev/null +++ b/rails/set-schema-search-path.md @@ -0,0 +1,16 @@ +# Set Schema Search Path + +By default the schema search path for a PostgreSQL database is going to be +`"$user", public`. Tables created by a Rails migration are going to end up +on the `public` schema by default. If your application has other schemas in +play, then you may want to ensure that those schemas are also on the schema +search path. This can be accomplished by adding the `schema_search_path` +setting to your `database.yml` file. For instance, to include both the +`legacy` and `public` schema in the Postgres search path, add the following +line: + +```ruby +schema_search_path: "legacy,public" +``` + +h/t Jack Christensen