teoljungberg / fx

Versioned database functions and triggers for Rails
MIT License
763 stars 77 forks source link

Allow defining schema where functions and triggers are retrieved #96

Closed louim closed 1 year ago

louim commented 2 years ago

Hey!

We use this gem in combination with https://github.com/rails-on-services/apartment. Like that gem recommends, we install extensions into a separate schema that is used throughout the application. We would also like to be able to create function in a different schema than the public one, eg:

CREATE OR REPLACE FUNCTION shared_extensions.my_function(...

The "creating" part works as expected, but because this line is hardcoded to look into the public schema, the functions aren't dumped to the schema.rb. https://github.com/teoljungberg/fx/blob/94b49971e6def226dfbdc6092cf9a3b1d990665e/lib/fx/adapters/postgres/functions.rb#L22

Would you be open to adding a way to configure the schema lookup?

teoljungberg commented 1 year ago

I have worked very little with having different schemas for multi-tenancy, I've instead split the database and had different instances.

Since I have no real experience with it, I'm cautious about adding support for it as this seems quite specific.