# Postgresql schemas (search\_path)

**URL:** https://discourse.rom-rb.org/t/postgresql-schemas-search-path/669
**Category:** Uncategorized
**Created:** [December 30, 2024, 12:08pm UTC](https://discourse.rom-rb.org/t/postgresql-schemas-search-path/669 "2024-12-30T12:08:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![krautcat](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/krautcat/32/334_2.png) [@krautcat](https://discourse.rom-rb.org/u/krautcat)
#### Post date: [December 30, 2024, 12:08pm UTC](https://discourse.rom-rb.org/t/postgresql-schemas-search-path/669/1 "2024-12-30T12:08:46Z")

</div>

Hi there,

I have a setup of PostgreSQL database with multiple schemas. They have some tables with the same name.

Is there any possibility use multiple gateways for different search\_paths?

---

<div class="post-metadata">

### Author: ![alassek](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/alassek/32/260_2.png) [@alassek](https://discourse.rom-rb.org/u/alassek)
#### Post date: [January 4, 2025, 2:25am UTC](https://discourse.rom-rb.org/t/postgresql-schemas-search-path/669/2 "2025-01-04T02:25:55Z")

</div>

Welcome @krautcat! Yes, you can do this. If you show me how you’re defining your gateways presently I can give you more personalized advice, but in general it would look like this:

```ruby
ROM.container(
  default: [:sql, database_url, search_path: 'public'],
  legacy: [:sql, database_url, search_path: 'alternate']
) do |config|
    # setup code goes here...
end

```

alternately, you can define gateways separately first

```ruby
default = ROM::Gateway.setup(:sql, database_url, search_path: 'public')
alternate = ROM::Gateway.setup(:sql, database_url, search_path: ['alternate', 'public'])

ROM::Configuration.new(default:, alternate:) do |config|
  # setup code goes here...
end

```

`search_path` in this example is a [Connection Option](http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html) for the Sequel driver. This means you could also embed it as a query param into the DATABASE\_URL, but I think doing it in Ruby is more clean.

---

<div class="post-metadata">

### Author: ![krautcat](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/krautcat/32/334_2.png) [@krautcat](https://discourse.rom-rb.org/u/krautcat)
#### Post date: [January 23, 2025, 6:35pm UTC](https://discourse.rom-rb.org/t/postgresql-schemas-search-path/669/3 "2025-01-23T18:35:32Z")

</div>

Sorry for late reply.

Thank you, I’ve done it, and everything works!
