-
Notifications
You must be signed in to change notification settings - Fork 57
Description
When loading an CSV file that has self referencing links within it, as long as the data which is being referenced is above the data which is referring to it then the data should load.
Scheme Sample
//// CHANGE name=init-rforganisationcommand-table
CREATE TABLE rf_organisationcommand (
commandname character varying(50),
commandcode character varying(10),
parentcommandid uuid,
commandid uuid NOT NULL
);
GO
//// CHANGE name=pkey1
ALTER TABLE ONLY public.rf_organisationcommand
ADD CONSTRAINT rf_organisationcommand_pkey PRIMARY KEY (commandid);
GO
Sample Data
"commandname","commandcode","parentcommandid","commandid"
"HQ","HQ",,"705B9DB2-7A8E-48C6-8DDC-5781BFE2CFB9"
"Department 1","DEPT1","705B9DB2-7A8E-48C6-8DDC-5781BFE2CFB9","7C06246F-4CB1-43B4-BED4-25225A989F95"
"Department 2","DEPT2","705B9DB2-7A8E-48C6-8DDC-5781BFE2CFB9","a4448d97-14f8-419b-8946-fa00a6eb9a83"
"Department 3,"DEPT3","705B9DB2-7A8E-48C6-8DDC-5781BFE2CFB9","2D0C51AA-18BD-4DB3-BA1E-FE44EBB313B0"
"TEAMA","TEAMA","a4448d97-14f8-419b-8946-fa00a6eb9a83","5AC0F3E4-71AF-4F1C-8654-B0BC11ADE1B6"
"TEAMB","TEAMB","a4448d97-14f8-419b-8946-fa00a6eb9a83","59BCECC9-2DB7-45D1-B5CA-78CB3E6B2440"
As you can see here HQ has three departments each of which can have children.
Within Postgres the following command would load the SQL natively.
postgres=# copy rf_organisationcommand from '/staticdata/rf_organisationcommand.csv' CSV HEADER;
I have also noticed that I need to run the deploy several times to enable all the other files to import data correctly as it does not always import the files in the correct dependancy order. Is there a way in the metadata to help this?