     -- This table will contain 1 record per IMT per logic tree realization
     -- for a given calculation.
     id SERIAL PRIMARY KEY,
+    lt_realization_id INTEGER NOT NULL,
     imt VARCHAR NOT NULL,
     -- stores a pickled numpy array for intermediate results
     -- array is 2d: sites x IMLs

REFERENCES uiapi.hazard_calculation(id)
ON DELETE CASCADE;

-- idata.lt_realization to uiapi.site_data FK
ALTER TABLE idata.lt_realization
ADD CONSTRAINT idata_lt_realization_site_data_fk
FOREIGN KEY (site_data_id)
REFERENCES idata.site_data(id)
ON DELETE RESTRICT;

-- idata.source_progress to idata.lt_realization FK
ALTER TABLE idata.source_progress
ADD CONSTRAINT idata_source_progress_lt_realization_fk

REFERENCES hzrdi.parsed_source(id)
ON DELETE CASCADE;

-- idata.hazard_curve_progress to idata.lt_realization FK
ALTER TABLE idata.hazard_curve_progress
ADD CONSTRAINT idata_hazard_curve_progress_lt_realization_fk
FOREIGN KEY (lt_realization_id)
REFERENCES idata.lt_realization(id)
ON DELETE CASCADE;

-- idata.site_data to uiapi.hazard_calculation FK
ALTER TABLE idata.site_data
ADD CONSTRAINT idata_site_data_hazard_calculation_fk
