From dd89aa6ff1f762c394309708e3fc4d64d6e895e5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 17 Feb 2023 19:42:14 +0100 Subject: [PATCH] improve title comment block --- sql/import.sql | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sql/import.sql b/sql/import.sql index 91428e5..1f2440a 100644 --- a/sql/import.sql +++ b/sql/import.sql @@ -42,7 +42,7 @@ INSERT INTO country (id, name, countrycode) FROM ( SELECT DISTINCT ON (country) country1 FROM import.choix_personnes WHERE country1 IS NOT NULL ) t WHERE NOT EXISTS ( SELECT 1 FROM country WHERE name::jsonb = t.country1 ); --- 5. Complete table maritalstatus +-- 5. Complete table marital_status ALTER TABLE import.choix_personnes ADD COLUMN maritalstatus1 JSONB; UPDATE import.choix_personnes SET maritalstatus1=json_build_object('fr', trim(maritalstatus)) WHERE maritalstatus!=''; INSERT INTO chill_person_marital_status (id, name) @@ -70,7 +70,7 @@ INSERT INTO chill_person_household_position (id, label, sharehousehold, allowhol CROSS JOIN max_ordering WHERE NOT EXISTS ( SELECT 1 FROM chill_person_household_position WHERE label::jsonb = t.household_position1 ); --- 8. Complete closingmotive +-- 8. Complete table accompanying_period_closingmotive ALTER TABLE import.choix_periodes ADD COLUMN closingmotive1 JSONB; UPDATE import.choix_periodes SET closingmotive1=json_build_object('fr', trim(closingmotive)) WHERE closingmotive!=''; WITH max_ordering AS ( SELECT MAX(ordering) as max_ordering FROM chill_person_accompanying_period_closingmotive ) @@ -82,7 +82,7 @@ INSERT INTO chill_person_accompanying_period_closingmotive (id, name, active, pa CROSS JOIN max_ordering WHERE NOT EXISTS ( SELECT 1 FROM chill_person_accompanying_period_closingmotive WHERE name::jsonb = t.closingmotive1 ); --- 9. Complete origin +-- 9. Complete table accompanying_period_origin ALTER TABLE import.choix_periodes ADD COLUMN origin1 JSONB; UPDATE import.choix_periodes SET origin1=json_build_object('fr', trim(origin)) WHERE origin!=''; INSERT INTO chill_person_accompanying_period_origin (id, label, noactiveafter) @@ -90,7 +90,7 @@ INSERT INTO chill_person_accompanying_period_origin (id, label, noactiveafter) FROM ( SELECT DISTINCT ON (origin) origin1 FROM import.choix_periodes WHERE origin1 IS NOT NULL ) t WHERE NOT EXISTS ( SELECT 1 FROM chill_person_accompanying_period_origin WHERE label::jsonb = t.origin1 ); --- 10. Complete user_job +-- 10. Complete table user_job ALTER TABLE import.choix_periodes ADD COLUMN job1 JSONB; UPDATE import.choix_periodes SET job1=json_build_object('fr', trim(job)) WHERE job!=''; INSERT INTO chill_main_user_job (id, label, active) @@ -98,7 +98,7 @@ INSERT INTO chill_main_user_job (id, label, active) FROM ( SELECT DISTINCT ON (job) job1 FROM import.choix_periodes WHERE job1 IS NOT NULL ) t WHERE NOT EXISTS( SELECT 1 FROM chill_main_user_job WHERE label::jsonb = t.job1 ); --- 11. Complete acp_scopes +-- 11. Complete table Scopes ALTER TABLE import.choix_periodes ADD COLUMN acp_scopes1 JSONB; UPDATE import.choix_periodes SET acp_scopes1=json_build_object('fr', trim(acp_scopes)) WHERE acp_scopes!=''; INSERT INTO scopes (id, name, active) @@ -106,13 +106,13 @@ INSERT INTO scopes (id, name, active) FROM ( SELECT DISTINCT ON (acp_scopes) acp_scopes1 FROM import.choix_periodes WHERE acp_scopes1 IS NOT NULL ) t WHERE NOT EXISTS ( SELECT 1 FROM scopes WHERE name::jsonb = t.acp_scopes1 ); --- 12. Complete referrers +-- 12. Complete table Users (acp referrer) INSERT INTO users (id, username, password, enabled, locked, attributes, label) SELECT nextval('users_id_seq'), t.referrer, '', false, false, '[]', t.referrer FROM ( SELECT DISTINCT ON (referrer) referrer FROM import.choix_periodes WHERE referrer <> '') t WHERE NOT EXISTS ( SELECT 1 FROM users WHERE username::text = t.referrer ); --- 13. Complete Social Issues +-- 13. Complete table SocialIssues ALTER TABLE import.choix_periodes ADD COLUMN parent1 jsonb; UPDATE import.choix_periodes SET parent1=json_build_object('fr', upper(trim(parent))) WHERE parent !=''; ALTER TABLE import.choix_periodes ADD COLUMN enfant1 jsonb; @@ -136,11 +136,15 @@ INSERT INTO chill_person_social_issue (id, parent_id, title, ordering) WHERE title::jsonb = t.enfant1 AND parent_id = (SELECT id FROM chill_person_social_issue WHERE title::jsonb = t.parent1)); +-- 14. Complete table WorkSocialActions + -- -- DOWN -- +-- Undo 14. + -- Undo 13. DELETE FROM chill_person_social_issue USING import.choix_periodes i WHERE parent_id IN ( SELECT id FROM chill_person_social_issue cpsi WHERE cpsi.title::jsonb = i.parent1::jsonb AND cpsi.parent_id IS NULL ); @@ -209,7 +213,7 @@ ALTER TABLE import.periodes DROP COLUMN closingdate1; -- ------------- -- personnes choices_list: gender --- periodes choices_list: intensity referrer job acp_scopes acp_socialissues work_socialaction +-- periodes choices_list: intensity -- tiers choices_list: civility kind profession category --