Project

General

Profile

« Previous | Next » 

Revision 48139

integrated (hopefully) all required changes from dnet40

View differences:

migrate_dsm.sql
1 1
-- cleanup the unnecessary functions: the following SQL produces the deletion statement list
2 2
SELECT 'DROP FUNCTION ' || ns.nspname || '.' || proname || '(' || oidvectortypes(proargtypes) || ');'
3
FROM pg_proc INNER JOIN pg_namespace ns ON (pg_proc.pronamespace = ns.oid)
4
WHERE ns.nspname = 'public'  order by proname;
3
FROM pg_proc
4
	INNER JOIN pg_namespace ns ON (pg_proc.pronamespace = ns.oid)
5
WHERE ns.nspname = 'public'
6
ORDER BY proname;
5 7

  
6 8
-- export the new dnet_dsm schema using
7 9
-- pg_dump --schema-only -h localhost -U dnet dnet_dsm | gzip -c > /tmp/dnet_dsm.sql.gz
......
10 12
-- psql -h localhost -U dnet dnet_openaireplus -f dnet_dsm.sql
11 13

  
12 14
-- insert into the new dsm_* tables picking the information from the old tables
13
insert into dsm_datasources 
14
select d.id, 
15
	d.officialname, 
16
	d.englishname, 
17
	d.websiteurl, 
18
	d.logourl, 
19
	d.contactemail, 
20
	d.latitude, 
21
	d.longitude, 
22
	d.timezone, 
23
	d.namespaceprefix,  
24
	ARRAY(select trim(s) from unnest(string_to_array(d.od_languages, ',')) as s)  as languages,
25
	ARRAY(select trim(s) from unnest(string_to_array(d.od_contenttypes, '-')) as s) as od_contenttypes,
26
	d.collectedfrom,
27
	d.dateofvalidation,
28
	d.optional1,
29
	d.optional2,
30
	d.datasourceclass as typology,
31
	d.provenanceactionclass as provenanceaction,
32
	d.dateofcollection,	
33
	d.typology as platform,
34
	d.activationid,
35
	d.description,
36
	d.releasestartdate,
37
	d.releaseenddate,
38
	d.missionstatementurl,
39
	d.dataprovider,
40
	d.serviceprovider,
41
	d.databaseaccesstype,
42
	d.datauploadtype,
43
	d.databaseaccessrestriction,
44
	d.datauploadrestriction,
45
	d.versioning,
46
	d.citationguidelineurl,
47
	d.qualitymanagementkind,
48
	d.pidsystems,
49
	d.certificates,
50
	d.aggregator,
51
	d.issn,
52
	d.eissn,
53
	d.lissn,
54
	d.registeredby,
55
	ARRAY_AGG(s.name) as subjects
56
from datasources d left outer join datasource_subject sd on (d.id = sd.datasource) left outer join subjects s on (sd.subject = s.id)
57
group by
58
	d.id;
15
INSERT INTO dsm_datasources
16
	SELECT
17
		d.id,
18
		d.officialname,
19
		d.englishname,
20
		d.websiteurl,
21
		d.logourl,
22
		d.contactemail,
23
		d.latitude,
24
		d.longitude,
25
		d.timezone,
26
		d.namespaceprefix,
27
		ARRAY(SELECT trim(s)
28
		      FROM unnest(string_to_array(d.od_languages, ',')) AS s)    AS languages,
29
		ARRAY(SELECT trim(s)
30
		      FROM unnest(string_to_array(d.od_contenttypes, '-')) AS s) AS od_contenttypes,
31
		d.collectedfrom,
32
		d.dateofvalidation,
33
		d.optional1,
34
		d.optional2,
35
		d.datasourceclass                                                AS typology,
36
		d.provenanceactionclass                                          AS provenanceaction,
37
		d.dateofcollection,
38
		d.typology                                                       AS platform,
39
		d.activationid,
40
		d.description,
41
		d.releasestartdate,
42
		d.releaseenddate,
43
		d.missionstatementurl,
44
		d.dataprovider,
45
		d.serviceprovider,
46
		d.databaseaccesstype,
47
		d.datauploadtype,
48
		d.databaseaccessrestriction,
49
		d.datauploadrestriction,
50
		d.versioning,
51
		d.citationguidelineurl,
52
		d.qualitymanagementkind,
53
		d.pidsystems,
54
		d.certificates,
55
		d.aggregator,
56
		d.issn,
57
		d.eissn,
58
		d.lissn,
59
		d.registeredby,
60
		ARRAY_AGG(s.name)                                                AS subjects
61
	FROM datasources d LEFT OUTER JOIN datasource_subject sd ON (d.id = sd.datasource)
62
		LEFT OUTER JOIN subjects s ON (sd.subject = s.id)
63
	GROUP BY
64
		d.id;
59 65

  
60
insert into dsm_api 
61
select a.id,
62
	a.protocolclass as protocol,
63
	a.datasource,
64
	a.contentdescriptionclass as contentdescription,
65
	a.active,
66
	a.removable,
67
	a.typologyclass as typology,
68
	a.compatibilityclass as compatibility,
69
	...
70
from api a left outer join apicollections ac on (a.id = ac.api)
71
group by a.id;
66
INSERT INTO dsm_api
67
	SELECT
68
		a.id,
69
		a.protocolclass           AS protocol,
70
		a.datasource,
71
		a.contentdescriptionclass AS contentdescription,
72
		a.active,
73
		a.removable,
74
		a.typologyclass           AS typology,
75
		a.compatibilityclass      AS compatibility,
76
...
77
FROM api a LEFT OUTER JOIN apicollections ac ON (a.id = ac.api)
78
GROUP BY a.id;
72 79

  
73 80

  
74
insert into dsm_apiparams
75
select a.param,
76
	a.edited? a.original!,
77
	a.api
78
from apicollections
79
where ...
81
INSERT INTO dsm_apiparams
82
	SELECT
83
		a.param,
84
		a.edited ? a.original !,
85
		a.api
86
	FROM apicollections
87
	WHERE ...
80 88

  
81 89

  
82
insert into dsm_organizations
83
select o.id,
84
	o.legalshortname,
85
 	o.legalname,
86
 	o.websiteurl,
87
 	o.logourl,
88
 	o.ec_legalbody,
89
 	o.ec_legalperson,
90
 	o.ec_nonprofit,
91
 	o.ec_researchorganization,
92
 	o.ec_highereducation,
93
 	o.ec_internationalorganizationeurinterests,
94
 	o.ec_internationalorganization,
95
 	o.ec_enterprise,
96
 	o.ec_smevalidated,
97
 	o.ec_nutscode,
98
 	o.countryclass as country,
99
	o.collectedfrom,
100
	o.optional1,
101
	o.optional2,
102
 	o.dateofcollection,
103
 	o.provenanceactionclass as provenanceaction
104
from organizations o;
90
INSERT INTO dsm_organizations
91
	SELECT
92
		o.id,
93
		o.legalshortname,
94
		o.legalname,
95
		o.websiteurl,
96
		o.logourl,
97
		o.ec_legalbody,
98
		o.ec_legalperson,
99
		o.ec_nonprofit,
100
		o.ec_researchorganization,
101
		o.ec_highereducation,
102
		o.ec_internationalorganizationeurinterests,
103
		o.ec_internationalorganization,
104
		o.ec_enterprise,
105
		o.ec_smevalidated,
106
		o.ec_nutscode,
107
		o.countryclass          AS country,
108
		o.collectedfrom,
109
		o.optional1,
110
		o.optional2,
111
		o.dateofcollection,
112
		o.provenanceactionclass AS provenanceaction
113
	FROM organizations o;
105 114

  
106
insert into dsm_datasource_organization
107
select dorg.datasource, dorg.organization
108
from datasource_organization dorg;
115
INSERT INTO dsm_datasource_organization
116
	SELECT
117
		dorg.datasource,
118
		dorg.organization
119
	FROM datasource_organization dorg;
109 120

  
110 121

  
111
insert into dsm_identities
112
select i.pid, i.issuertypeclass as issuertype
113
from identities i;
122
INSERT INTO dsm_identities
123
	SELECT
124
		i.pid,
125
		i.issuertypeclass AS issuertype
126
	FROM identities i;
114 127

  
115
insert into dsm_datasourcepids
116
select dp.datasource, dp.pid
117
from datasourcepids dp;
128
INSERT INTO dsm_datasourcepids
129
	SELECT
130
		dp.datasource,
131
		dp.pid
132
	FROM datasourcepids dp;
118 133

  
119 134

  
120
insert into dsm_organizationpids
121
select op.organization, op.pid
122
from organizationpids op;
135
INSERT INTO dsm_organizationpids
136
	SELECT
137
		op.organization,
138
		op.pid
139
	FROM organizationpids op;
123 140

  
124 141

  
125 142

  

Also available in: Unified diff