funders api: created dsm_service_funder table + updated view
This commit is contained in:
parent
8e353f7fa3
commit
fb947fde62
|
@ -1,6 +1,15 @@
|
|||
ALTER TABLE dsm_organizations ADD COLUMN registered_funder boolean;
|
||||
|
||||
CREATE VIEW funders_view AS SELECT
|
||||
|
||||
CREATE TABLE dsm_service_funder (
|
||||
_dnet_resource_identifier_ varchar(2048) DEFAULT 'temp_'||md5(clock_timestamp()::text)||'_'||md5(random()::text),
|
||||
service text NOT NULL REFERENCES dsm_services(id) ON DELETE CASCADE,
|
||||
funder text NOT NULL REFERENCES dsm_organizations(id) ON DELETE CASCADE,
|
||||
last_collection_date date,
|
||||
PRIMARY KEY(funder, service)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE VIEW funders_view AS SELECT
|
||||
o.id AS id,
|
||||
o.legalshortname AS legalshortname,
|
||||
o.legalname AS legalname,
|
||||
|
@ -13,13 +22,13 @@ CREATE VIEW funders_view AS SELECT
|
|||
array_agg(DISTINCT pids.issuertype||' @=@ '||pids.pid) AS pids
|
||||
FROM
|
||||
dsm_organizations o
|
||||
JOIN dsm_service_organization so ON (o.id = so.organization)
|
||||
JOIN dsm_services s ON (so.service = s.id)
|
||||
JOIN projects p ON (p.collectedfrom = s.id)
|
||||
JOIN dsm_service_funder sf ON (o.id = sf.funder)
|
||||
JOIN dsm_services s ON (sf.service = s.id)
|
||||
LEFT OUTER JOIN dsm_organizationpids opids ON (o.id = opids.organization)
|
||||
LEFT OUTER JOIN dsm_identities pids ON (opids.pid = pids.pid)
|
||||
GROUP BY o.id;
|
||||
|
||||
GRANT ALL ON dsm_service_funder TO dnetapi;
|
||||
GRANT ALL ON funders_view TO dnetapi;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue