Skip to content

Commit

Permalink
fix(gate): Fixed migration errors, added Legal Entities name migratio…
Browse files Browse the repository at this point in the history
…n to name_parts
  • Loading branch information
alexsilva-CGI committed Jun 30, 2023
1 parent e07bb0a commit c9ad31c
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ ADD CONSTRAINT fk_address_name_parts FOREIGN KEY (address_id) REFERENCES logisti
ADD CONSTRAINT fk_legal_entity_name_parts FOREIGN KEY (legal_entity_id) REFERENCES legal_entities,
ADD CONSTRAINT fk_sites_name_parts FOREIGN KEY (site_id) REFERENCES sites;

INSERT INTO name_parts (address_id, name_part)
SELECT id, name FROM logistic_addresses WHERE name IS NOT NULL;
INSERT INTO name_parts (id, address_id, name_part, created_at, updated_at, uuid)
SELECT nextval('bpdm_sequence'), id, name, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, uuid
FROM logistic_addresses WHERE name IS NOT NULL;

INSERT INTO name_parts (site_id, name_part)
SELECT id, name FROM sites WHERE name IS NOT NULL;
INSERT INTO name_parts (id, site_id, name_part, created_at, updated_at, uuid)
SELECT nextval('bpdm_sequence'), id, name, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, uuid
FROM sites WHERE name IS NOT NULL;

INSERT INTO name_parts (id, legal_entity_id, name_part, created_at, updated_at, uuid)
SELECT nextval('bpdm_sequence'), id, name_shortname, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, uuid
FROM legal_entities WHERE name_shortname IS NOT NULL;

ALTER TABLE logistic_addresses
DROP COLUMN IF EXISTS name;
Expand Down

0 comments on commit c9ad31c

Please sign in to comment.