Installing pg isok

From sokwedb
Jump to navigation Jump to search

Pg_isok is "The Warning System".

When to Install

Pg_isok is installed in its own schema, isolated from all of SokweDB's schemas. It only need be installed once, upon database creation. Removing or re-installing SokweDB's schemas using the build tools do not interfere with the content of Pg_isok's schema.

Of course, if an entire database is dropped, re-created, and restored from backup, pg_isok will also need to be restored. Depending on the situation, this may involve re-installing pg_isok and then restoring the content of its tables.

Installing The Warning System (pg_isok)

The pg_isok PostgreSQL extension is used as SokweDB's "Warning System". Because SokweDB is in the cloud, pg_isok must be installed from a SQL script.

To generate the SQL needed to install pg_isok, follow the cloud instructions found in the pg_isok documentation. SokweDB expects installation in a schema named isok.

Install pg_isok in each database.

After installation, permissions must be granted.

The following example shows the steps involved to install pg_isok version 0.1.4, using psql, and to grant the expected permissions. (The name of the SQL file, included with \i, will vary with the pg_isok version.)


SET ROLE TO admin;
CREATE SCHEMA isok;
GRANT USAGE ON SCHEMA isok TO reader;
GRANT USAGE ON SCHEMA isok TO writer;

\i ../pg_isok_cloud--0.1.4.sql

-- IQ_TYPES
GRANT SELECT ON isok.iq_types TO reader;
GRANT SELECT ON isok.iq_types TO writer;
GRANT INSERT ON isok.iq_types TO writer;
GRANT UPDATE ON isok.iq_types TO writer;
GRANT DELETE ON isok.iq_types TO writer;

-- IR_TYPES
GRANT SELECT ON isok.ir_types TO reader;
GRANT SELECT ON isok.ir_types TO writer;
GRANT INSERT ON isok.ir_types TO writer;
GRANT UPDATE ON isok.ir_types TO writer;
GRANT DELETE ON isok.ir_types TO writer;

-- ISOK_QUERIES
GRANT SELECT ON isok.isok_queries TO reader;
GRANT SELECT ON isok.isok_queries TO writer;
GRANT INSERT ON isok.isok_queries TO writer;
GRANT UPDATE ON isok.isok_queries TO writer;
GRANT DELETE ON isok.isok_queries TO writer;

-- ISOK_RESULTS
GRANT SELECT ON isok.isok_results TO reader;
GRANT SELECT ON isok.isok_results TO writer;
GRANT INSERT ON isok.isok_results TO writer;
GRANT UPDATE ON isok.isok_results TO writer;
GRANT DELETE ON isok.isok_results TO writer;

GRANT SELECT ON isok.isok_results_irid_seq TO reader;
GRANT SELECT ON isok.isok_results_irid_seq TO writer;
GRANT UPDATE ON isok.isok_results_irid_seq TO writer;

-- run_isok_queries()
GRANT EXECUTE ON FUNCTION isok.run_isok_queries() TO writer;
GRANT EXECUTE ON FUNCTION isok.run_isok_queries(TEXT) TO writer;