20 lines
807 B
PL/PgSQL
20 lines
807 B
PL/PgSQL
-- {{product.name}}: operational data store schema (runs on the ods service).
|
|
--
|
|
-- The product owns one PostgreSQL schema. pg_graphql reflects only the schemas on the
|
|
-- search_path, and the product's RPC endpoint (030_api.sql) sets the search_path to this
|
|
-- schema, so this is what scopes the GraphQL API to the product.
|
|
|
|
CREATE SCHEMA {{product.schema}};
|
|
|
|
COMMENT ON SCHEMA {{product.schema}} IS E'@graphql({"inflect_names": true, "introspection": true, "max_rows": 100})';
|
|
|
|
-- Maintains updated_at on every row change. Used by all product tables (020_tables.sql).
|
|
-- updated_at is the freshness signal carried on the outbound topics and into the lake.
|
|
CREATE FUNCTION {{product.schema}}.set_updated_at() RETURNS trigger
|
|
LANGUAGE plpgsql AS $$
|
|
BEGIN
|
|
NEW.updated_at := now();
|
|
RETURN NEW;
|
|
END
|
|
$$;
|