← Back to team overview

dhis2-devs team mailing list archive

Re: Global ranges

 

Ok, I think I would like to recommend ignoring the file I sent and rather
redefine the table and then run Thanh's first SQL, for a total of three
statements. They can all be run in one go, just paste the following into the
SQL window in PgAdmin III:

DROP TABLE minmaxdataelement;

CREATE TABLE minmaxdataelement
(
  minmaxdataelementid SERIAL NOT NULL,
  sourceid integer,
  dataelementid integer,
  "minvalue" integer,
  "maxvalue" integer,
  generated boolean,
  categoryoptioncomboid integer,
  CONSTRAINT minmaxdataelement_pkey PRIMARY KEY (minmaxdataelementid),
  CONSTRAINT fk_minmaxdataelement_categoryoptioncomboid FOREIGN KEY
(categoryoptioncomboid)
      REFERENCES categoryoptioncombo (categoryoptioncomboid) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk_minmaxdataelement_dataelementid FOREIGN KEY (dataelementid)
      REFERENCES dataelement (dataelementid) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk_minmaxdataelement_sourceid FOREIGN KEY (sourceid)
      REFERENCES source (sourceid) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (OIDS=FALSE);

insert into minmaxdataelement(sourceid, dataelementid, minvalue, maxvalue)
select organisationunitid, dataelementid, 0, 99 from organisationunit,
dataelement;

Follow ups

References