Project

General

Profile

1
CREATE TABLE IF NOT EXISTS fundingpaths (
2
	_dnet_resource_identifier_ CHARACTER VARYING(2048) DEFAULT 'temp_' || md5(clock_timestamp() :: TEXT) || '_' || md5(random() :: TEXT),
3
	id                         CHARACTER VARYING(512) PRIMARY KEY,
4
	path                       TEXT NOT NULL,
5
	funder                     CHARACTER VARYING(512) REFERENCES organizations (id),
6
	jurisdiction               CHARACTER VARYING(16),
7
	description                CHARACTER VARYING(512),
8
	optional1                  CHARACTER VARYING(255),
9
	optional2                  CHARACTER VARYING(255)
10
);
11

    
12
CREATE TABLE IF NOT EXISTS project_fundingpath (
13
	_dnet_resource_identifier_ CHARACTER VARYING(2048) DEFAULT 'temp_' || md5(clock_timestamp() :: TEXT) || '_' || md5(random() :: TEXT),
14
	funding                    CHARACTER VARYING(255) NOT NULL REFERENCES fundingpaths (id),
15
	project                    CHARACTER VARYING(255) NOT NULL REFERENCES projects (id),
16
	startdate                  DATE,
17
	enddate                    DATE,
18
	semanticclass              CHARACTER VARYING(255) REFERENCES class (code),
19
	semanticscheme             CHARACTER VARYING(255) REFERENCES scheme (code),
20
	optional1                  CHARACTER VARYING(255),
21
	optional2                  CHARACTER VARYING(255),
22
	PRIMARY KEY (funding, project)
23
);
24

    
25
UPDATE datasources
26
SET namespaceprefix = 'wt__________'
27
WHERE id = 'openaire____::wellcometrust';
28

    
29
-- European Commission FP7
30

    
31
delete from project_fundingpath where funding ='ec__________::EC::FP7::UNKNOWN::UNKNOWN';
32
delete from fundingpaths where id = 'ec__________::EC::FP7::UNKNOWN::UNKNOWN';
33

    
34
-- FCT
35
-- copy the good ones from the other db
36
\copy  (select * from project_fundingpath where project like 'fct\_\_\_\_\_\_\_\_\_%') TO '/tmp/fct_project_fundingpath-prod.sql' CSV;
37
-- do the following on the bad ones
38
delete from project_fundingpath where project like 'fct\_\_\_\_\_\_\_\_\_%';
39

    
40
CREATE TEMP TABLE fct (
41
_dnet_resource_identifier_ VARCHAR(2048),
42
funding varchar(255),
43
project varchar(255),
44
startdate date,
45
enddate date,
46
semanticclass varchar(255),
47
semanticscheme varchar(255),
48
optional1 varchar(255),
49
optional2 varchar(255)
50
);
51

    
52
 \copy fct from '/tmp/fct_project_fundingpath-prod.sql' CSV;
53
 INSERT INTO project_fundingpath select * from fct;
54
 -- fct is a temp table and will be dropped when you log out
55

    
56
-- SFI
57
delete from project_fundingpath where funding = 'sfi_________::SFI::SFI US Ireland R&D Partnership - Planning Grant';
58
delete from project_fundingpath where funding ='sfi_________::SFI::SFI Stokes Professorship & Lectureship Programme';
59
delete from project_fundingpath where funding ='sfi_________::SFI::SFI US Ireland R&D Partnership';
60
delete from project_fundingpath where funding = 'sfi_________::SFI::China / Ireland Science & Technology Collaboration Research Fund�';
61
delete from fundingpaths  where id = 'sfi_________::SFI::China / Ireland Science & Technology Collaboration Research Fund�';
62
delete from fundingpaths  where id ='sfi_________::SFI::SFI US Ireland R&D Partnership';
63
delete from fundingpaths  where id = 'sfi_________::SFI::SFI Stokes Professorship & Lectureship Programme';
64
delete from fundingpaths  where id = 'sfi_________::SFI::SFI US Ireland R&D Partnership - Planning Grant';
65
select count(distinct project) from project_fundingpath where project like 'sfi%';
66
select count(distinct id) from projects where id like 'sfi%';
67

    
68
-- WT
69
delete from project_fundingpath where project like 'wt%';
70
delete from fundingpaths where id like 'wt%';
71

    
72
-- SNSF
73
delete from project_fundingpath where project like 'snsf%';
74
delete from fundingpaths where id like 'snsf%';
75

    
76
-- ARC
77
delete from project_fundingpath where project like 'arc%';
78
delete from fundingpaths where id like 'arc%';
79

    
80
-- RCUK
81
delete from project_fundingpath where project like 'rcuk%';
82
delete from fundingpaths where id like 'rcuk%';
83

    
84

    
85

    
(10-10/26)