Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Schema support #52

Open
vjustov opened this issue Feb 18, 2016 · 3 comments
Open

Multi Schema support #52

vjustov opened this issue Feb 18, 2016 · 3 comments
Labels

Comments

@vjustov
Copy link

vjustov commented Feb 18, 2016

I'm using hair-trigger with a multi-tenant application that uses Postgres schemas to separate each tenant's information. Doing schema_load on a newly created tenant errors out, because on the schema.rb the CREATE FUNCTION script has the public schema hardcoded, ex:

  # no candidate create_trigger statement could be found, creating an adapter-specific one
  execute(<<-TRIGGERSQL)
CREATE OR REPLACE FUNCTION public.tsv_body_trigger()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
BEGIN
    NEW.tsv_body := to_tsvector('pg_catalog.spanish', coalesce(NEW.content,''));
    RETURN NULL;
END;
$function$
  TRIGGERSQL

This causes that the SQL that creates the trigger errors out because the function is not defined in the schema:

  # no candidate create_trigger statement could be found, creating an adapter-specific one
  execute("CREATE TRIGGER tsv_body_trigger AFTER INSERT OR UPDATE ON \"pg_search_documents\" FOR EACH ROW EXECUTE PROCEDURE tsv_body_trigger()")
@vjustov
Copy link
Author

vjustov commented Feb 20, 2016

Also, I'm diving into the code to see if I can pinpoint the problem, but when trying to run the tests for the gem, I get these errors: error creating database: createdb: could not connect to database template1: FATAL: role "hairtrigger" does not exist.
I'd recommend adding a contributing part to the readme, to avoid these types of issues and maybe opening a gitter room, so that people can talk over there, and ask help.

@jenseng
Copy link
Owner

jenseng commented Feb 4, 2017

Ooof, sorry for the radio silence :( ... I'm not using hairtrigger in any of my projects anymore, so I don't spend a whole lot of time on it these days. That said, I'd be open to reviewing a PR to address this 👍

I'll see about tweaking either documenting the spec db setup, or tweaking how it works so it just authenticates as USER (probably ok for most setups).

@jenseng jenseng added the feature label Feb 4, 2017
@sandeep-patle1508
Copy link
Contributor

Hi,

We are trying to set up multiple databases with our Rails 6 application. Due to this gem we are facing an issue.

When we are running rails db:migrate

it is overwriting the primary schema.rb file with secondary schema file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants