33-34. Format phone numbers
This commit is contained in:
parent
25510c1efe
commit
139dd6209a
@ -6,6 +6,7 @@
|
|||||||
-- * Avant de migrer (UP), il faut d'abord importer les codes postaux !!!
|
-- * Avant de migrer (UP), il faut d'abord importer les codes postaux !!!
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
-- 1. Adjust Type cast for id columns
|
-- 1. Adjust Type cast for id columns
|
||||||
ALTER TABLE import.personnes ALTER COLUMN id TYPE INTEGER USING (id::integer);
|
ALTER TABLE import.personnes ALTER COLUMN id TYPE INTEGER USING (id::integer);
|
||||||
ALTER TABLE import.periodes ALTER COLUMN id TYPE INTEGER USING (id::integer);
|
ALTER TABLE import.periodes ALTER COLUMN id TYPE INTEGER USING (id::integer);
|
||||||
@ -206,13 +207,24 @@ UPDATE import.periodes SET acp_scopes1=json_build_object('fr', trim(acp_scopes))
|
|||||||
ALTER TABLE import.periodes ADD COLUMN intensity1 text;
|
ALTER TABLE import.periodes ADD COLUMN intensity1 text;
|
||||||
UPDATE import.periodes SET intensity1='occasional'; UPDATE import.periodes SET intensity1='regular' WHERE intensity='regular';
|
UPDATE import.periodes SET intensity1='occasional'; UPDATE import.periodes SET intensity1='regular' WHERE intensity='regular';
|
||||||
|
|
||||||
|
-- 33. Format mobile numbers
|
||||||
|
ALTER TABLE import.personnes ADD column mobilenumber1 text;
|
||||||
|
UPDATE import.personnes SET mobilenumber1=NULLIF(regexp_replace(mobilenumber, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||||
|
UPDATE import.personnes SET mobilenumber1=regexp_replace(mobilenumber1, '^0', '') WHERE mobilenumber1 like '0%'; -- remove first 0 prefix
|
||||||
|
-- UPDATE import.personnes SET mobilenumber1=regexp_replace(mobilenumber1, '(.*)', '+32\1'); -- add belgium intl prefix
|
||||||
|
|
||||||
-- 33. Prepare required default dates
|
-- 34. Format phone numbers
|
||||||
|
ALTER TABLE import.personnes ADD column phonenumber1 text;
|
||||||
|
UPDATE import.personnes SET phonenumber1=NULLIF(regexp_replace(phonenumber, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||||
|
UPDATE import.personnes SET phonenumber1=regexp_replace(phonenumber1, '^0', '') WHERE phonenumber1 like '0%'; -- remove first 0 prefix
|
||||||
|
-- UPDATE import.personnes SET phonenumber1=regexp_replace(phonenumber1, '(.*)', '+32\1'); -- add belgium intl prefix
|
||||||
|
-- SELECT mobilenumber, mobilenumber1, phonenumber, phonenumber1 FROM import.personnes;
|
||||||
|
|
||||||
|
|
||||||
|
-- 35. Prepare required default dates
|
||||||
-- address_validfrom1 | household_startdate1
|
-- address_validfrom1 | household_startdate1
|
||||||
-- acp_openingdate1
|
-- acp_openingdate1
|
||||||
|
|
||||||
-- 34. Format phone numbers
|
|
||||||
-- phonenumber | mobilenumber
|
|
||||||
|
|
||||||
-- 40. Prepare id mapping before insertion
|
-- 40. Prepare id mapping before insertion
|
||||||
ALTER TABLE import.personnes ADD column person_id BIGINT;
|
ALTER TABLE import.personnes ADD column person_id BIGINT;
|
||||||
@ -270,6 +282,12 @@ SELECT setval('chill_person_person_id_seq', (SELECT max(id) FROM chill_person_pe
|
|||||||
-- Undo 40.
|
-- Undo 40.
|
||||||
ALTER TABLE import.personnes DROP COLUMN person_id;
|
ALTER TABLE import.personnes DROP COLUMN person_id;
|
||||||
|
|
||||||
|
-- Undo 34.
|
||||||
|
ALTER TABLE import.personnes DROP column phonenumber1;
|
||||||
|
|
||||||
|
-- Undo 33.
|
||||||
|
ALTER TABLE import.personnes DROP column mobilenumber1;
|
||||||
|
|
||||||
-- Undo 32.
|
-- Undo 32.
|
||||||
ALTER TABLE import.periodes DROP COLUMN intensity1;
|
ALTER TABLE import.periodes DROP COLUMN intensity1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user