-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow specifying the schema where pgcrypto is (or can be) installed #3657
Comments
@dilame These don't seem to be Hasura specific routines. These would either be default Postgres routines or routines added by some Postgres extentions. |
But it appeared right after i deployed hasura. I started developing this database 2 weeks ago, i'm perfectly know all the routines and extensions in it. This routines wasn't exist before i give hasura access. |
@rikinsk Does Hasura try to install pgcrypto if its not present? |
@tirumaraiselvan I don't believe so. Installing it is a part of the Postgres permissions setup instructions we have in docs but I dont believe it is done automatically. @ecthiender can add more insights |
@tirumaraiselvan @rikinsk looks like it does https://github.com/hasura/graphql-engine/blob/master/server/src-lib/Hasura/Server/Migrate.hs#L95 Not sure why we create it in public schema though. |
|
Maybe we should install this extension in |
I agree. We can maybe provide a flag to specify the schema in which |
One more thing: i run command on existing db before hasura init CREATE EXTENSION pgcrypto SCHEMA utils; After it hasura doesn't start. I think it's more of a bug than an enhancement. {"exec_status":"FatalError",
"hint":"No function matches the given name and argument types. You might need to add explicit type casts.",
"message":"function gen_random_uuid() does not exist",
"status_code":"42883",
"description":null},"arguments":[]},"path":"$","error":"postgres query error","code":"unexpected"} |
@dilame You will need to include the schema Pls make sure that it is set permanently for the user (role) and not just for the current session: https://stackoverflow.com/questions/2875610/permanently-set-postgresql-schema-path |
@tirumaraiselvan I have the same issue as @dilame, and doing a |
@W1M0R Can you check if it's permanently set?
|
@tirumaraiselvan The code here tries to create pgcrypto in the public schema if it does not exist https://github.com/hasura/graphql-engine/blob/master/server/src-lib/Hasura/Server/Migrate.hs#L117 Also, if I run your query I get no results. |
@W1M0R Yes, the original issue still exists. Currently, if pgcrypto is not installed then Hasura will install it in |
Hey guys, what's with this issue? :) I just started a new project and it happened again |
The silent installation of the extension is awful!
hasura_uuid.control
hasura_uuid--1.0.sql
In the graphql-engine settings, select the functions used. |
Not sure if it's related but I'm getting an error on Hasura Cloud that's preventing even making a connection, [
{
"internal": {
"statement": "/* We define our own uuid generator function that uses gen_random_uuid() underneath.\n Since the column default is not directly referencing gen_random_uuid(),\n it prevents the column default to be dropped when pgcrypto or public schema is dropped unwittingly.\n\n See https://github.com/hasura/graphql-engine/issues/4217\n */\nCREATE OR REPLACE FUNCTION hdb_catalog.gen_hasura_uuid() RETURNS uuid AS\n -- We assume gen_random_uuid() is available in the search_path.\n -- This may not be true but we can't do much till https://github.com/hasura/graphql-engine/issues/3657\n'select gen_random_uuid()' LANGUAGE SQL;\n\nCREATE TABLE hdb_catalog.hdb_source_catalog_version(\n version TEXT NOT NULL,\n upgraded_on TIMESTAMPTZ NOT NULL\n);\n\nCREATE UNIQUE INDEX hdb_source_catalog_version_one_row\nON hdb_catalog.hdb_source_catalog_version((version IS NOT NULL));\n\nCREATE TABLE hdb_catalog.event_log\n(\n id TEXT DEFAULT hdb_catalog.gen_hasura_uuid() PRIMARY KEY,\n schema_name TEXT NOT NULL,\n table_name TEXT NOT NULL,\n trigger_name TEXT NOT NULL,\n payload JSONB NOT NULL,\n delivered BOOLEAN NOT NULL DEFAULT FALSE,\n error BOOLEAN NOT NULL DEFAULT FALSE,\n tries INTEGER NOT NULL DEFAULT 0,\n created_at TIMESTAMP DEFAULT NOW(),\n /* when locked IS NULL the event is unlocked and can be processed */\n locked TIMESTAMPTZ,\n next_retry_at TIMESTAMP,\n archived BOOLEAN NOT NULL DEFAULT FALSE\n);\n\nCREATE INDEX ON hdb_catalog.event_log (trigger_name);\nCREATE INDEX ON hdb_catalog.event_log (locked);\nCREATE INDEX ON hdb_catalog.event_log (delivered);\nCREATE INDEX ON hdb_catalog.event_log (created_at);\n\nCREATE TABLE hdb_catalog.event_invocation_logs\n(\n id TEXT DEFAULT hdb_catalog.gen_hasura_uuid() PRIMARY KEY,\n event_id TEXT,\n status INTEGER,\n request JSON,\n response JSON,\n created_at TIMESTAMP DEFAULT NOW(),\n\n FOREIGN KEY (event_id) REFERENCES hdb_catalog.event_log (id)\n);\n\nCREATE INDEX ON hdb_catalog.event_invocation_logs (event_id);\n\nCREATE OR REPLACE FUNCTION\n hdb_catalog.insert_event_log(schema_name text, table_name text, trigger_name text, op text, row_data json)\n RETURNS text AS $$\n DECLARE\n id text;\n payload json;\n session_variables json;\n server_version_num int;\n trace_context json;\n BEGIN\n id := gen_random_uuid();\n server_version_num := current_setting('server_version_num');\n IF server_version_num >= 90600 THEN\n session_variables := current_setting('hasura.user', 't');\n trace_context := current_setting('hasura.tracecontext', 't');\n ELSE\n BEGIN\n session_variables := current_setting('hasura.user');\n EXCEPTION WHEN OTHERS THEN\n session_variables := NULL;\n END;\n BEGIN\n trace_context := current_setting('hasura.tracecontext');\n EXCEPTION WHEN OTHERS THEN\n trace_context := NULL;\n END;\n END IF;\n payload := json_build_object(\n 'op', op,\n 'data', row_data,\n 'session_variables', session_variables,\n 'trace_context', trace_context\n );\n INSERT INTO hdb_catalog.event_log\n (id, schema_name, table_name, trigger_name, payload)\n VALUES\n (id, schema_name, table_name, trigger_name, payload);\n RETURN id;\n END;\n$$ LANGUAGE plpgsql;\n",
"prepared": false,
"error": {
"exec_status": "FatalError",
"hint": "No function matches the given name and argument types. You might need to add explicit type casts.",
"message": "function gen_random_uuid() does not exist",
"status_code": "42883",
"description": null
},
"arguments": []
},
"definition": "default",
"reason": "database query error",
"type": "source"
}
] |
I started getting this error.. what is going on here.. what's the solution? |
psql cli run |
Hey folks, this is possible as of v2.11.0-beta.1 . There are 2 places where pgrcypto is required: in metadata db and source db (only if using event triggers) For your metadata DB, pls set If you are using event triggers on your source db, then pls set |
Right after i installed it to heroku and input my existing database URL. Now i have 43 routines with names like
crypto
,pgp_*****_*****
mixed with my own business-logic routines. It's a bad experience for me 馃樋 You are usinghdb_***
schemas, why you need to modify mypublic
?The text was updated successfully, but these errors were encountered: