HARPgroup / r-dh-ecohydro

A set of R scripts for generating Ecological Limit Functions (ELF), storing the modeled output with REST in drupal VAHydro (dH), and a set of scripts for querying and analyzing processed ELF data
0 stars 1 forks source link

Update entity_type on erom properties (flows, DA) #22

Closed rburghol closed 6 years ago

rburghol commented 6 years ago

Use SQl to rapidly do this, you have to make sure to update both the dh_properties table and the dh_properties_revision table.

-- inventory the proposed changes if we just do it without extra filters
select a.ftype, a.bundle, b.entity_type, count(*) from dh_feature as a 
left outer join dh_properties as b 
on (b.featureid = a.hydroid
  and (
      b.entity_type = 'dh_feature'
      or b.entity_type is null
      or b.entity_type = ''
    )
)
where b.varid in (select hydroid from dh_variabledefinition where vocabulary = 'nhdplus_flow_data')
group by a.ftype, a.bundle, b.entity_type;

-- just do it for all variables associated with the EROM  
update dh_properties set entity_type = 'dh_feature'
where varid in (select hydroid from dh_variabledefinition where vocabulary = 'nhdplus_flow_data')
and entity_type = ''
and featureid in (select hydroid from dh_feature where ftype = 'nhdplus')
;

update dh_properties_revision set entity_type = 'dh_feature'
where varid in (select hydroid from dh_variabledefinition where vocabulary = 'nhdplus_flow_data')
and entity_type = ''
and featureid in (select hydroid from dh_feature where ftype = 'nhdplus')
;