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

Error creating tenant with uuid column #85

Closed
edbond opened this issue Jul 8, 2020 · 2 comments
Closed

Error creating tenant with uuid column #85

edbond opened this issue Jul 8, 2020 · 2 comments

Comments

@edbond
Copy link

edbond commented Jul 8, 2020

Steps to reproduce

Run
Apartment::Tenant.create("nfl")
in console

[nfl] SQL (0.3ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"  []
...
[nfl]  (6.3ms) CREATE TABLE "squirrels" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, ...

Traceback (most recent call last):
        1: from (irb):2
ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR:  function gen_random_uuid() does not exist)
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Expected behavior

No errors

Actual behavior

ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR: function gen_random_uuid() does not exist)
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

System configuration

  • Database: (Tell us what database and its version you use.)

Postgresql server 11.6

  • Apartment version:

    ros-apartment (2.7.1)

  • Apartment config (in config/initializers/apartment.rb or so):

    config.pg_excluded_names = %w[uuid_generate_v4 gen_random_uuid]
    config.tenant_names = -> { DomainSettings.pluck(:name) }

    • use_schemas: (true or false)
      default = true
  • Rails (or ActiveRecord) version:

Rails 6.0.2.1

  • Ruby version:

ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]

@rpbaltazar
Copy link
Contributor

Thank you for reporting. I have not yet used the uuid solution, so i have not seen the problem yet. will try to recreate and address the issue over the weekend as well. will keep the ticket updated

@edbond
Copy link
Author

edbond commented Jul 10, 2020

Thank you Rui. I have found issue in parent repository
influitive/apartment#86

The fix for me was to move pgcrypto extension to pg_catalog:

ALTER EXTENSION pgcrypto SET SCHEMA pg_catalog;

Still don't understand why the function not found after creating pgcrypto extension.

@edbond edbond closed this as completed Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants