-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
This is assuming you setup a new Hasura container + Postgres container via the instructions found here: https://docs.hasura.io/1.0/graphql/manual/getting-started/docker-simple.html
You can find the container name with docker ps and then running docker exec <container-name> pg_dump -U postgres -d postgres.
Is it possible for pg_dump to only return something like this on a cloud server?
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.1 (Debian 12.1-1.pgdg100+1)
-- Dumped by pg_dump version 12.1 (Debian 12.1-1.pgdg100+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- PostgreSQL database dump complete
--
Running the exact same command on my machine gives me something more elaborate:
--
-- PostgreSQL database dump
--
-- Dumped from database version 12.1 (Debian 12.1-1.pgdg100+1)
-- Dumped by pg_dump version 12.1 (Debian 12.1-1.pgdg100+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: hdb_catalog; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA hdb_catalog;
ALTER SCHEMA hdb_catalog OWNER TO postgres;
--
-- Name: hdb_views; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA hdb_views;
ALTER SCHEMA hdb_views OWNER TO postgres;
--
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
--
-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
--
-- Name: hdb_schema_update_event_notifier(); Type: FUNCTION; Schema: hdb_catalog; Owner: postgres
--
CREATE FUNCTION hdb_catalog.hdb_schema_update_event_notifier() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
instance_id uuid;
occurred_at timestamptz;
curr_rec record;
BEGIN
instance_id = NEW.instance_id;
occurred_at = NEW.occurred_at;
PERFORM pg_notify('hasura_schema_update', json_build_object(
'instance_id', instance_id,
'occurred_at', occurred_at
)::text);
RETURN curr_rec;
END;
$$;
ALTER FUNCTION hdb_catalog.hdb_schema_update_event_notifier() OWNER TO postgres;
--
-- Name: inject_table_defaults(text, text, text, text); Type: FUNCTION; Schema: hdb_catalog; Owner: postgres
--
CREATE FUNCTION hdb_catalog.inject_table_defaults(view_schema text, view_name text, tab_schema text, tab_name text) RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
r RECORD;
BEGIN
FOR r IN SELECT column_name, column_default FROM information_schema.columns WHERE table_schema = tab_schema AND table_name = tab_name AND column_default IS NOT NULL LOOP
EXECUTE format('ALTER VIEW %I.%I ALTER COLUMN %I SET DEFAULT %s;', view_schema, view_name, r.column_name, r.column_default);
END LOOP;
END;
$$;
ALTER FUNCTION hdb_catalog.inject_table_defaults(view_schema text, view_name text, tab_schema text, tab_name text) OWNER TO postgres;
--
-- Name: insert_event_log(text, text, text, text, json); Type: FUNCTION; Schema: hdb_catalog; Owner: postgres
--
CREATE FUNCTION hdb_catalog.insert_event_log(schema_name text, table_name text, trigger_name text, op text, row_data json) RETURNS text
LANGUAGE plpgsql
AS $$
DECLARE
id text;
payload json;
session_variables json;
server_version_num int;
BEGIN
id := gen_random_uuid();
server_version_num := current_setting('server_version_num');
IF server_version_num >= 90600 THEN
session_variables := current_setting('hasura.user', 't');
ELSE
BEGIN
session_variables := current_setting('hasura.user');
EXCEPTION WHEN OTHERS THEN
session_variables := NULL;
END;
END IF;
payload := json_build_object(
'op', op,
'data', row_data,
'session_variables', session_variables
);
INSERT INTO hdb_catalog.event_log
(id, schema_name, table_name, trigger_name, payload)
VALUES
(id, schema_name, table_name, trigger_name, payload);
RETURN id;
END;
$$;
ALTER FUNCTION hdb_catalog.insert_event_log(schema_name text, table_name text, trigger_name text, op text, row_data json) OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: event_invocation_logs; Type: TABLE; Schema: hdb_catalog; Owner: postgres
--
CREATE TABLE hdb_catalog.event_invocation_logs (
id text DEFAULT public.gen_random_uuid() NOT NULL,
event_id text,
status integer,
request json,
response json,
created_at timestamp without time zone DEFAULT now()
);
ALTER TABLE hdb_catalog.event_invocation_logs OWNER TO postgres;
--
-- Name: event_log; Type: TABLE; Schema: hdb_catalog; Owner: postgres
--
CREATE TABLE hdb_catalog.event_log (
id text DEFAULT public.gen_random_uuid() NOT NULL,
schema_name text NOT NULL,
table_name text NOT NULL,
trigger_name text NOT NULL,
payload jsonb NOT NULL,
delivered boolean DEFAULT false NOT NULL,
error boolean DEFAULT false NOT NULL,
tries integer DEFAULT 0 NOT NULL,
created_at timestamp without time zone DEFAULT now(),
locked boolean DEFAULT false NOT NULL,
next_retry_at timestamp without time zone,
archived boolean DEFAULT false NOT NULL
);
ALTER TABLE hdb_catalog.event_log OWNER TO postgres;
--
-- Name: event_triggers; Type: TABLE; Schema: hdb_catalog; Owner: postgres
--
CREATE TABLE hdb_catalog.event_triggers (
name text NOT NULL,
type text NOT NULL,
schema_name text NOT NULL,
table_name text NOT NULL,
configuration json,
comment text
);
ALTER TABLE hdb_catalog.event_triggers OWNER TO postgres;
--
-- Name: hdb_allowlist; Type: TABLE; Schema: hdb_catalog; Owner: postgres
--
CREATE TABLE hdb_catalog.hdb_allowlist (
collection_name text
);
ALTER TABLE hdb_catalog.hdb_allowlist OWNER TO postgres;
--
-- Name: hdb_check_constraint; Type: VIEW; Schema: hdb_catalog; Owner: postgres
--
CREATE VIEW hdb_catalog.hdb_check_constraint AS
SELECT (n.nspname)::text AS table_schema,
(ct.relname)::text AS table_name,
(r.conname)::text AS constraint_name,
pg_get_constraintdef(r.oid, true) AS "check"
FROM ((pg_constraint r
JOIN pg_class ct ON ((r.conrelid = ct.oid)))
JOIN pg_namespace n ON ((ct.relnamespace = n.oid)))
WHERE (r.contype = 'c'::"char");
ALTER TABLE hdb_catalog.hdb_check_constraint OWNER TO postgres;
...
And this output isn't even the full dump, it's only a fraction of it.
Is a fresh new postgres server setup with Hasura meant to return no SQL data (first output)? Or is it meant to be something like the second output where there is some data?
Here are some of my other questions:
- If the second output is intended, then what causes the first output?
- If we get the first output as a result, what can we do to "add the missing SQL"?
This may be the cause of this related issue, where it won't work with GitHub Actions. It makes incorporating Hasura into a DevOps pipeline difficult:
#3638