You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ClinicalTrialsDataProcessing/DockerContainers/ClinicalTrialHistory/docker-entrypoint-initdb.d/020_HttpSchema.sql

42 lines
980 B
SQL

CREATE SCHEMA http;
/*
The purpose of this schema, tables, and associated roles to process HTTP responses.
I may even include a table to keep track of the XML responses
*/
/*
Add a role to manage permissions on the http schema
*/
CREATE ROLE http_requestor;
GRANT CONNECT ON DATABASE aact_db to http_requestor;
GRANT USAGE ON SCHEMA http TO http_requestor;
GRANT INSERT,SELECT ON ALL TABLES IN SCHEMA http TO http_requestor;
/* Create tables related to http requests
As not every request will have an xml doc, split them.
*/
CREATE TABLE IF NOT EXISTS http.responses (
id SERIAL PRIMARY KEY,
nct VARCHAR(15),
version SMALLINT
url VARCHAR(255),
response_code SMALLINT,
response_date DATE
);
CREATE TABLE IF NOT EXISTS http.xml_documents (
id SERIAL PRIMARY KEY,
xml XML,
CONSTRAINT http_response
FOREIGN KEY (id)
REFERENCES http.responses (id)
ON DELETE CASCADE --remove xml if the request is deleted
);