teksi / district_heating

Future TEKSI distance heating module
GNU General Public License v3.0
0 stars 0 forks source link

Migration importing data in pipe_point and subclasses #27

Open sjib opened 1 month ago

sjib commented 1 month ago

@jpdupuy Here the code as discussed for your migration:

--- Add additional DEREFERABLE constraints to data model

20240527_oorel_od_pipe_point_feed_pipe_point

ALTER TABLE tdh_od.pipe_point_feed ALTER CONSTRAINT oorel_od_pipe_point_feed_pipe_point DEFERRABLE INITIALLY DEFERRED; ALTER TABLE tdh_od.pipe_point_norma ALTER CONSTRAINT oorel_od_pipe_point_norma_pipe_point DEFERRABLE INITIALLY DEFERRED;

And maybe add in FME this call before the whole import or do it manually before running the import: SET CONSTRAINTS ALL DEFERRED;

and then set back at the end

jpdupuy commented 1 month ago

@sjib ALTER TABLE tdh_od.pipe_point_normal ALTER CONSTRAINT oorel_od_pipe_point_normal_pipe_point DEFERRABLE INITIALLY DEFERRED

I followed your instructions, but did have any success 👎 with fme (also run set constraints all deferred (sql to run before write) Bulk copy failed on table 'tdh_od.trench_line' using delimiter ':'. Error was 'ERROR: insert or update on table "trench_line" violates foreign key constraint "rel_trench_line_trench" DETAIL: Key (fk_trench)=(1) is not present in table "trench".

sjib commented 1 month ago

@jpdupuy This is not the problem of pipe_point subclasses anymore (?) but of trench_line.fk_trench You have to set DEFERRABLE INITIALLY DEFERRED for that relation also. If this is a new error then the first step was a success.

sjib commented 1 month ago

If this is successful I can add DEFERRABLE INITIALLY DEFERRED to all relations as with tww

jpdupuy commented 1 month ago

@sjib Yes, it was successful, thanks