Compare commits
24 Commits
dev
...
feat-add-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a9966d84c | ||
|
|
ced84f50c2 | ||
|
|
04d1e35ba4 | ||
|
|
c388967ebd | ||
|
|
8481acfe5d | ||
|
|
5a90126f98 | ||
| 45755bf797 | |||
| 08e87503f0 | |||
| 20517a109b | |||
| c17b2ae524 | |||
| 5bfc7f4a02 | |||
| 6b8ca0caa3 | |||
|
|
c5f892c27d | ||
|
|
82f69f9845 | ||
|
|
fd4e68faa8 | ||
|
|
3651b1a09b | ||
|
|
db52c72d22 | ||
|
|
9c90e5ac07 | ||
|
|
543a4569fd | ||
|
|
36e3bf3b4b | ||
|
|
ddfe9b53b3 | ||
|
|
ca3ce608c0 | ||
|
|
4e866c2d8e | ||
|
|
6b11efd18e |
4
.env.example
Normal file
4
.env.example
Normal file
@@ -0,0 +1,4 @@
|
||||
POSTGRES_DB=chill-import
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
POSTGRES_PORT=5432
|
||||
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
112
README.md
Normal file → Executable file
112
README.md
Normal file → Executable file
@@ -1,31 +1,70 @@
|
||||
CHILL - Reprise de données
|
||||
==========================
|
||||
|
||||
Ce dépôt contient un script d'import qui s'applique à un canevas excel présenté au client. Le client remplit le fichier excel, puis le script insère les données dans la base de donnée.
|
||||
Ce dépôt contient un script d'import qui s'applique à un canevas excel présenté au client. Le client remplit le fichier excel, puis le script insère les données dans la base de donnée.
|
||||
|
||||
L'opération est semi-automatique et réduit considérablement le temps dédié à l'import en structurant le format des données en entrée. Par contre il y a toujours une série de manipulations, pour préparer et insérer les données correctement.
|
||||
L'opération est semi-automatique et réduit considérablement le temps dédié à l'import en structurant le format des données en entrée. Par contre il y a toujours une série de manipulations, pour préparer et insérer les données correctement.
|
||||
|
||||
Ces manipulations sont décrites ici.
|
||||
|
||||
|
||||
Le client a rempli le canevas. Une relecture du fichier est toujours nécessaire afin de repérer les éventuelles irrégularités.
|
||||
|
||||
## Procédure rapide
|
||||
|
||||
Pour l'import courant, la procédure recommandée est maintenant automatisée.
|
||||
|
||||
Pré-requis:
|
||||
- la base PostgreSQL cible doit être accessible
|
||||
- le schéma `import` est recréé automatiquement par le script
|
||||
- les fichiers csv nécessaires doivent être présents dans `csv/`
|
||||
|
||||
Commandes:
|
||||
|
||||
```bash
|
||||
cd /Users/boriswaaub/Documents/Projets/Clients/Champs-Libres/chill-import-from-canvas
|
||||
|
||||
# 1. Nettoyer les données précédemment importées
|
||||
PGPASSWORD='!ChangeMe!' psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -p 5454 -U app -d app -f sql/remove-import-data.sql
|
||||
|
||||
# 2. Charger les CSV dans le schéma import
|
||||
PGPASSWORD='!ChangeMe!' PGHOST=127.0.0.1 PGPORT=5454 PGUSER=app PGDATABASE=app ./import_all_csv.sh
|
||||
|
||||
# 3. Exécuter l'import applicatif
|
||||
PGPASSWORD='!ChangeMe!' psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -p 5454 -U app -d app -f sql/import.sql
|
||||
```
|
||||
|
||||
Vérification rapide:
|
||||
|
||||
```bash
|
||||
PGPASSWORD='!ChangeMe!' psql -h 127.0.0.1 -p 5454 -U app -d app -c "SELECT count(*) AS links_from_imported_periods FROM import.periodes ip JOIN chill_person_accompanying_period_social_issues aps ON aps.accompanyingperiod_id = ip.period_id;"
|
||||
```
|
||||
|
||||
Important:
|
||||
- `sql/import.sql` n'exécute plus le bloc `DOWN` automatiquement.
|
||||
- pour annuler un import, utiliser `sql/remove-import-data.sql`.
|
||||
- le bloc `DOWN` de `sql/import.sql` reste disponible uniquement si on le demande explicitement:
|
||||
|
||||
```bash
|
||||
PGPASSWORD='!ChangeMe!' psql -v ON_ERROR_STOP=1 -v run_down=1 -h 127.0.0.1 -p 5454 -U app -d app -f sql/import.sql
|
||||
```
|
||||
|
||||
## 1. Préparer les fichiers csv
|
||||
|
||||
Le fichier se compose de plusieurs feuilles, chacune doit être sauvée au format csv.
|
||||
|
||||
Pour préparer les fichiers on va:
|
||||
- nettoyer le fichier pour ne laisser en étiquette que les noms de colonnes en anglais.
|
||||
- ajouter une colonne de contôle en fin de ligne, par sécurité. Par exemple une colonne 'endcol' qui contient pour chaque cellule 'endrow'.
|
||||
- ajouter les doublequote lors de la sauvegarde du csv,
|
||||
- nettoyer le fichier pour ne laisser en étiquette que les noms de colonnes en anglais. Il faut donc supprimer les 4 premières lignes de chaque fichier + la 6ème ligne.
|
||||
(- ajouter une colonne de contôle en fin de ligne, par sécurité. Par exemple une colonne 'endcol' qui contient pour chaque cellule 'endrow'.)
|
||||
- ajouter les doublequote lors de la sauvegarde du csv,
|
||||
- enlever tous les line breaks et caractères spéciaux.
|
||||
|
||||
```bash
|
||||
# Exemple de remplacements exécutés sur les fichiers csv pour un import spécifique :
|
||||
$ sed -e :1 -e '$q' -e "/$CR\$/b" -e 'N;s/\n//;b1' < file.2.csv > file.3.csv
|
||||
$ sed -e :1 -e '$q' -e "/$CR\$/b" -e 'N;s/\n//;b1' < file.2.csv > file.3.csv
|
||||
$ sed -e 's#"end"#"end"\n#g' < file.3.csv > file.4.csv
|
||||
|
||||
# Exemple pour un autre import:
|
||||
$ cat file2.csv | sed -e 'N; s#_x000D_##g; s#\n##g; s/$CR//g' | tr "\n" " " > file3.csv
|
||||
# Exemple pour un autre import:
|
||||
$ cat file2.csv | sed -e 'N; s#_x000D_##g; s#\n##g; s/$CR//g' | tr "\n" " " > file3.csv
|
||||
$ sed -e 's#"endcol"#"endcol"\n#g; s#"endrow"#"endrow"\n#g' < file3.csv > file4.csv
|
||||
$ sed -e 's#^,##g; s#^ ##g' < file4.csv > file5.csv
|
||||
```
|
||||
@@ -38,14 +77,14 @@ On va insérer chaque feuille csv comme table à part entière d'un nouveau sch
|
||||
- import.choix_periodes
|
||||
- import.periodes
|
||||
|
||||
Pour réaliser cet import, on peut utiliser des outils tels que `pgfutter`, mais celui-ci peut s'avérer capricieux selon le fichier.
|
||||
Pour réaliser cet import, on peut utiliser des outils tels que `pgfutter`, mais celui-ci peut s'avérer capricieux selon le fichier.
|
||||
La meilleure méthode pour moi est de réaliser cette étape en local avec phpstorm, puis d'exporter le schéma `import` avec pg_dump avant de le transférer sur le serveur.
|
||||
|
||||
### 2.a Manipulations dans phpstorm
|
||||
|
||||
- S'il n'existe pas, créer le schéma `import`; s'il existe, s'assurer qu'il ne contient pas de tables ni de données.
|
||||
#### Importer le csv dans la db
|
||||
- ouvre le fichier csv > passe en onglet text > edit as table > set options:
|
||||
- ouvre le fichier csv > passe en onglet text > edit as table > set options:
|
||||
- cocher 'first row is header'
|
||||
- 'null value text': undefined (pas de champs null dans la table, mais un texte vide)
|
||||
- then > open table
|
||||
@@ -56,14 +95,39 @@ La meilleure méthode pour moi est de réaliser cette étape en local avec phpst
|
||||
- then > import
|
||||
#### Exporter en sql
|
||||
- créer un fichier `<client>-data.sql` vide
|
||||
- depuis chaque table du schéma `import`:
|
||||
- depuis chaque table du schéma `import`:
|
||||
- copier le DDL de la table dans le fichier (s'assurer d'ajouter le préfixe `import.` sur chaque requête)
|
||||
- export data > extractor: SQL-insert-multirow > copy to clipboard
|
||||
- export data > extractor: SQL-insert-multirow > copy to clipboard
|
||||
- coller les données dans `<client>-data.sql`
|
||||
|
||||
### 2.b Avec des fonctions Postgresql
|
||||
|
||||
On peut aussi utiliser la fonction `\copy` de psql pour charger un fichier csv dans les tables temporaires du schéma "import".
|
||||
|
||||
Tout d'abord, les tables du schéma "import" doivent être préparées avec le script `prepare-import.sql`.
|
||||
|
||||
Puis on importe les fichiers csv:
|
||||
|
||||
```bash
|
||||
psql chill-import
|
||||
chill-import=# \copy "import".choix_personnes FROM 'choix_personnes.csv' DELIMITER ',' CSV HEADER
|
||||
chill-import=# \copy "import".personnes FROM 'personnes.csv' DELIMITER ',' CSV HEADER
|
||||
chill-import=# \copy "import".choix_periodes FROM 'choix_periodes.csv' DELIMITER ',' CSV HEADER
|
||||
chill-import=# \copy "import".periodes FROM 'periodes.csv' DELIMITER ',' CSV HEADER
|
||||
chill-import=# \copy "import".choix_localisations FROM 'choix_localisations.csv' DELIMITER ',' CSV HEADER
|
||||
chill-import=# \copy "import".localisations FROM 'localisations.csv' DELIMITER ',' CSV HEADER
|
||||
```
|
||||
|
||||
Enfin, on exporte la base de données en sql:
|
||||
|
||||
```bash
|
||||
pg_dump chill-import --no-owner > <client>-data.sql
|
||||
```
|
||||
|
||||
|
||||
## 3. Import du schéma 'import' sur le serveur (safran)
|
||||
|
||||
- transférer le fichier `<client>-data.sql` sur le serveur (avec scp):
|
||||
- transférer le fichier `<client>-data.sql` sur le serveur (avec scp):
|
||||
```bash
|
||||
$ scp cyclo-data.sql debian@safran:~/data/tmp/
|
||||
```
|
||||
@@ -75,6 +139,14 @@ debian@safran:~/bin$ ls -l dump/ | tail -1
|
||||
-rw-r--r-- 1 postgres postgres 234954230 Mar 15 10:40 20230315-104003_cycloprod.sql
|
||||
```
|
||||
|
||||
ou bien simplement:
|
||||
|
||||
```bash
|
||||
sudo su postgres
|
||||
cd
|
||||
pg_dump -p 5436 laplateformereunionprod > laplateformereunionprod.sql
|
||||
```
|
||||
|
||||
- importer le fichier sql sur la base cible: `$ sudo su postgres -c 'psql -p5436'`
|
||||
```sql
|
||||
postgres=# \c cycloprod
|
||||
@@ -91,7 +163,7 @@ cycloprod=# \i '/home/debian/data/tmp/cyclo-data.sql'
|
||||
-- vérifier que le schéma import est en place
|
||||
cycloprod=# \dt import.*
|
||||
List of relations
|
||||
Schema | Name | Type | Owner
|
||||
Schema | Name | Type | Owner
|
||||
--------+-----------------+-------+----------
|
||||
import | choix_periodes | table | postgres
|
||||
import | choix_personnes | table | postgres
|
||||
@@ -100,7 +172,15 @@ cycloprod=# \dt import.*
|
||||
(4 rows)
|
||||
```
|
||||
|
||||
## 4. Exécution du script de migration
|
||||
ou bien simplement:
|
||||
|
||||
```bash
|
||||
sudo su postgres
|
||||
psql -p 5436 laplateformereunionprod < /tmp/chill-import-lpreunion.sql
|
||||
```
|
||||
|
||||
|
||||
## 4. Exécution du script de migration
|
||||
|
||||
Se fait dans la console postgresql, en tant que user postgres, en étant connecté à la base de donnée cible.
|
||||
|
||||
|
||||
BIN
canvas/chill_canevas_reprise-de-données.xlsx
Executable file
BIN
canvas/chill_canevas_reprise-de-données.xlsx
Executable file
Binary file not shown.
@@ -1 +1 @@
|
||||
closingmotive,origin,acp_scopes,job,referrer,parent,enfant,acp_socialissues,work_socialactions,street,extra,streetnumber,postcode,country,address_text,endcol
|
||||
closingmotive,origin,acp_scopes,job,referrer,parent,enfant,acp_social_issues,work_social_action,street,extra,streetnumber,postcode,country
|
||||
|
||||
|
0
csv/choix_personnes.dist.csv
Normal file → Executable file
0
csv/choix_personnes.dist.csv
Normal file → Executable file
0
csv/periodes.dist.csv
Normal file → Executable file
0
csv/periodes.dist.csv
Normal file → Executable file
0
csv/personnes.dist.csv
Normal file → Executable file
0
csv/personnes.dist.csv
Normal file → Executable file
BIN
csv_stemm/260311−Paramétrage.xlsx
Normal file
BIN
csv_stemm/260311−Paramétrage.xlsx
Normal file
Binary file not shown.
24
csv_stemm/choix_localisations.csv
Normal file
24
csv_stemm/choix_localisations.csv
Normal file
@@ -0,0 +1,24 @@
|
||||
title,addressRequired,availableForUsers,contactData,defaultFor,editableByUsers
|
||||
Mairie / Commune,,,,,
|
||||
Guichet d’accueil,,,,,
|
||||
Domicile de l’usager,,,,,
|
||||
épicerie sociale,,,,,
|
||||
Ecole,,,,,
|
||||
Lycée,,,,,
|
||||
Université,,,,,
|
||||
Ambassade,,,,,
|
||||
Consulat,,,,,
|
||||
Tribunal,,,,,
|
||||
Ministère,,,,,
|
||||
Banque,,,,,
|
||||
Prison,,,,,
|
||||
Centre de rétention,,,,,
|
||||
Foyer ONA,,,,,
|
||||
Hébergement d'urgence,,,,,
|
||||
WAK,,,,,
|
||||
ASTI,,,,,
|
||||
Office social,,,,,
|
||||
Hôpital,,,,,
|
||||
Services Logement,,,,,
|
||||
Centre thérapeutique,,,,,
|
||||
Administration,,,,,
|
||||
|
146
csv_stemm/choix_periodes.csv
Normal file
146
csv_stemm/choix_periodes.csv
Normal file
@@ -0,0 +1,146 @@
|
||||
closingmotive,origin,acp_scopes,job,referrer,parent,enfant,acp_social_issues,work_social_action,street,extra,streetnumber,postcode,country
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,Orienter vers une structure compétente,,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,vérifier droits d'accès,,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,affiliation volontaire,,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,Orienter vers OS (pour prise en charge de l'affiliation volontaire et/ou tiers payant),,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,projet CUSS,,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,Prévention et Sensibilisation,,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,"Rédaction recours (CNS, Médecin contrôle,...)",,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,prise en charge de facture médicale ou autre,,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,"Réorienter chez médecin gratuit (Médecins du Monde, Stëmm vun der Strooss)",,,,,
|
||||
,,,,,Santé,Accès aux soins,Santé > Accès aux soins,Demande assistance dépendance,,,,,
|
||||
,,,,,Santé,Santé mentale,Santé > Santé mentale,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Santé,Santé mentale,Santé > Santé mentale,Prise de rendez-vous médicaux,,,,,
|
||||
,,,,,Santé,Santé mentale,Santé > Santé mentale,Réorientation service compétent,,,,,
|
||||
,,,,,Santé,Consultation médicale – Stëmm,Santé > Consultation médicale – Stëmm,enquête Dr Stëmm,,,,,
|
||||
,,,,,Santé,Consultation médicale – Stëmm,Santé > Consultation médicale – Stëmm,"établir une prise en charge pour spécialiste, laboratoire, radiologie,...",,,,,
|
||||
,,,,,Santé,Consultation médicale – Stëmm,Santé > Consultation médicale – Stëmm,établir un bon pharmacie,,,,,
|
||||
,,,,,Santé,Consultation médicale – Stëmm,Santé > Consultation médicale – Stëmm,prise en charge de facture médicale ou autre,,,,,
|
||||
,,,,,Santé,Handicap,Santé > Handicap,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Santé,Handicap,Santé > Handicap,Prise de rendez-vous médicaux,,,,,
|
||||
,,,,,Santé,Handicap,Santé > Handicap,Réorientation service compétent,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Enquête sociale,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Préparation de la demande,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Transmission de la demande au Ministère de la Santé,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),"Echange avec MISA, CCSS, CNS",,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Entretien régulier,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Prise de rendez-vous médicaux,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Demande assistance dépéndance,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Accompagnement physique au rendez-vous,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Suivi social,,,,,
|
||||
,,,,,Santé,CUSS (Couverture Universelle des Soins de Santé),Santé > CUSS (Couverture Universelle des Soins de Santé),Art. 32,,,,,
|
||||
,,,,,Justice,Accès aux droits,Justice > Accès aux droits,Enquête sociale,,,,,
|
||||
,,,,,Justice,Accès aux droits,Justice > Accès aux droits,Vérifier les possibilités d'accès aux droits,,,,,
|
||||
,,,,,Justice,Accès aux droits,Justice > Accès aux droits,aide à la constitution d'un dossier pour l'OS ou autre,,,,,
|
||||
,,,,,Justice,Accès aux droits,Justice > Accès aux droits,Vérifier possibilité d'une adresse,,,,,
|
||||
,,,,,Justice,Accès aux droits,Justice > Accès aux droits,Vérifier si autorisation de travailler,,,,,
|
||||
,,,,,Justice,Accès aux droits,Justice > Accès aux droits,"Informer, conseiller, expliquer",,,,,
|
||||
,,,,,Justice,Accès aux droits,Justice > Accès aux droits,Orienter vers réseau (bas seuil ou spécialisé dans la problématique),,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Enquête sociale,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Vérifier les possibilités d'accès aux droits,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Vérifier possibilité d'une adresse,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Vérifier si autorisation de travailler,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,"Informer, conseiller",,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,"Orienter vers réseau (ASTI, CLAE, HUT, LISKO, ONA...)",,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,(Renouvellement) titre de séjour,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Actualisation documents d'identité,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Contacter MAI,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Contacter MAE,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Assistance judiciaire (recours),,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Centre de rétention/Maison retour,,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Retour volontaire (IOM),,,,,
|
||||
,,,,,Justice,Accès aux droits – Migration,Justice > Accès aux droits – Migration,Regroupement familial,,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,Demande d'assistance judiciaire,,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,Réorientation permanence judiciaire gratuite,,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,"recherche de renseignements concernant l'affaire (police, avocat, parquet,..)",,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,Ombudsman/OKAJU,,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,"Demande renseignement service spécialisé (Mieterschutz, UCL, Syndicats,...)",,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,Explication courrier,,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,Rédaction recours,,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,Echange services pénitentiaires,,,,,
|
||||
,,,,,Justice,Accès aux droits – Juridique,Justice > Accès aux droits – Juridique,"Contact service compétent (avocat, huissier, créanciers,...)",,,,,
|
||||
,,,,,Justice,Protection Adulte,Justice > Protection Adulte,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Justice,Protection Adulte,Justice > Protection Adulte,"Prise de contact service compétent (violence.lu, SCAS,...)",,,,,
|
||||
,,,,,Justice,Protection Adulte,Justice > Protection Adulte,"Réorientation service compétent (violence.lu, SCAS,...)",,,,,
|
||||
,,,,,Justice,Protection Adulte,Justice > Protection Adulte,Réorientation Police (Plainte),,,,,
|
||||
,,,,,Justice,Protection Adulte,Justice > Protection Adulte,Réorientation Service Info Traite,,,,,
|
||||
,,,,,Justice,Protection Adulte,Justice > Protection Adulte,Demande d'assistance judiciaire,,,,,
|
||||
,,,,,Justice,Protection Adulte – besoins spécifiques,Justice > Protection Adulte – besoins spécifiques,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Justice,Protection Adulte – besoins spécifiques,Justice > Protection Adulte – besoins spécifiques,"Réorientation service compétent (TACS, Avocat,...)",,,,,
|
||||
,,,,,Justice,Protection Adulte – besoins spécifiques,Justice > Protection Adulte – besoins spécifiques,Faire une demande tutelle/curatelle,,,,,
|
||||
,,,,,Emploi,Sans emploi,Emploi > Sans emploi,"Informer, conseiller, expliquer",,,,,
|
||||
,,,,,Emploi,Sans emploi,Emploi > Sans emploi,Rédaction de CV,,,,,
|
||||
,,,,,Emploi,Sans emploi,Emploi > Sans emploi,Rédaction de LM,,,,,
|
||||
,,,,,Emploi,Sans emploi,Emploi > Sans emploi,Réorientation vers ACT ou similaire,,,,,
|
||||
,,,,,Emploi,Sans emploi,Emploi > Sans emploi,Intérim,,,,,
|
||||
,,,,,Emploi,Sans emploi,Emploi > Sans emploi,Inscription Adem,,,,,
|
||||
,,,,,Emploi,problèmes,Emploi > problèmes,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Emploi,problèmes,Emploi > problèmes,Echange employeur,,,,,
|
||||
,,,,,Emploi,problèmes,Emploi > problèmes,Echange ONIS,,,,,
|
||||
,,,,,Emploi,problèmes,Emploi > problèmes,Echange ARIS,,,,,
|
||||
,,,,,Emploi,problèmes,Emploi > problèmes,Contact ITM,,,,,
|
||||
,,,,,Emploi,problèmes,Emploi > problèmes,Rédaction courrier,,,,,
|
||||
,,,,,Emploi,problèmes,Emploi > problèmes,Réorientation Service Info Traite,,,,,
|
||||
,,,,,Emploi,ISP (TUC où autre),Emploi > ISP (TUC où autre),Echange avec ADEM,,,,,
|
||||
,,,,,Emploi,ISP (TUC où autre),Emploi > ISP (TUC où autre),Echange avec employeur,,,,,
|
||||
,,,,,Emploi,ISP (TUC où autre),Emploi > ISP (TUC où autre),Réorienter vers l'ONIS,,,,,
|
||||
,,,,,Emploi,ISP (TUC où autre),Emploi > ISP (TUC où autre),Echanger avec l'ARIS,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Signer la procuration,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Signer la dénonciation de procuration,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Faire un bilan de la situation financière,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Etablir un plan budgétaire ou d'apurement,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Réévaluation en cas de besoin,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,"Contacter les créanciers, huissiers,...",,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,aide à la constitution d'un dossier pour l'OS,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Ouvrir un compte bancaire,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Clôturer un compte bancaire,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Effectuer un virement,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Donner de l'argent liquide,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,Accès aide alimentaire,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,mise en place d'ordres permanents,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,faire une avance,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,"vérifier les possibilités d'accès (Revis, Rpgh, chômage, pension, invalidité,allocations familiales...)",,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,entamer les démarches requises,,,,,
|
||||
,,,,,Finance,Guidance budgétaire,Finance > Guidance budgétaire,"rédiger un recours (ADEM, FNS,...)",,,,,
|
||||
,,,,,Logement,Accès au logement,Logement > Accès au logement,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Logement,Accès au logement,Logement > Accès au logement,Faire demande RENLA,,,,,
|
||||
,,,,,Logement,Accès au logement,Logement > Accès au logement,Faire une demande de subvention loyer,,,,,
|
||||
,,,,,Logement,Accès au logement,Logement > Accès au logement,Faire une demande d'aide pour garanti locative de l'état,,,,,
|
||||
,,,,,Logement,Accès au logement,Logement > Accès au logement,Orienter vers OS pour garantie locative,,,,,
|
||||
,,,,,Logement,Accès au logement,Logement > Accès au logement,Faire un recours en cas de notification de déguerpissement,,,,,
|
||||
,,,,,Logement,Accès au logement,Logement > Accès au logement,Orienter vers logement d'urgence,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,Réorientation vers office social,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,Demande d'adresse de référence,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,Demande RENLA,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,Demande logements sociaux,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,Orientation pour adresse courrier,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,Orientation structure d'urgence,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,faire une demande pour maison de repos \ maison de soins,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,actualisation annuelle de la demande logement social,,,,,
|
||||
,,,,,Logement,perte/absence,Logement > perte/absence,actualisation subvention loyer,,,,,
|
||||
,,,,,Logement,Adresse de référence,Logement > Adresse de référence,Enquête sociale (vérifier les conditions d'accès),,,,,
|
||||
,,,,,Logement,Adresse de référence,Logement > Adresse de référence,Instruction de la demande,,,,,
|
||||
,,,,,Logement,Adresse de référence,Logement > Adresse de référence,Réorientation vers service compétent,,,,,
|
||||
,,,,,Logement,Adresse de référence,Logement > Adresse de référence,Accompagnement social,,,,,
|
||||
,,,,,Logement,Adresse de référence,Logement > Adresse de référence,Clôture de la demande,,,,,
|
||||
,,,,,Logement,Logement Encadré,Logement > Logement Encadré,Entretien d'évaluation (avant déménagement),,,,,
|
||||
,,,,,Logement,Logement Encadré,Logement > Logement Encadré,Rédiger contrat avec objectifs à atteindre,,,,,
|
||||
,,,,,Logement,Logement Encadré,Logement > Logement Encadré,Visites régulières,,,,,
|
||||
,,,,,Logement,Logement Encadré,Logement > Logement Encadré,"Aides démarches (administratives, quotidiens, etc)",,,,,
|
||||
,,,,,Logement,Logement Encadré,Logement > Logement Encadré,Si objectifs atteint -> sortie logement,,,,,
|
||||
,,,,,Logement,Logement Encadré,Logement > Logement Encadré,échange avec bailleur social,,,,,
|
||||
,,,,,Logement,Logement Encadré,Logement > Logement Encadré,compléter révision annuelle du loyer,,,,,
|
||||
,,,,,Logement,Insalubrité,Logement > Insalubrité,"Ecouter, informer, conseiller",,,,,
|
||||
,,,,,Logement,Insalubrité,Logement > Insalubrité,Chercher le dialogue avec le bailleur,,,,,
|
||||
,,,,,Logement,Insalubrité,Logement > Insalubrité,Echange Mairie,,,,,
|
||||
,,,,,Logement,Insalubrité,Logement > Insalubrité,Echange centre d'hébergement,,,,,
|
||||
,,,,,Logement,Insalubrité,Logement > Insalubrité,Procédure d'insalubrité,,,,,
|
||||
,,,,,Logement,Insalubrité,Logement > Insalubrité,Rédaction de recours,,,,,
|
||||
,,,,,Logement,Insalubrité,Logement > Insalubrité,Echange avocat,,,,,
|
||||
,,,,,Logement,médiation,Logement > médiation,Echange avec Bailleur,,,,,
|
||||
,,,,,Logement,médiation,Logement > médiation,Echange Mairie,,,,,
|
||||
,,,,,Logement,médiation,Logement > médiation,Echange centre d'hébergement,,,,,
|
||||
|
59
csv_stemm/choix_tiers.csv
Normal file
59
csv_stemm/choix_tiers.csv
Normal file
@@ -0,0 +1,59 @@
|
||||
acronym,nom,categorie
|
||||
CHL,Centre Hospitalier de Luxembourg,hopital
|
||||
CHEM,Centre Hospitalier Emile Mayrisch,hopital
|
||||
HRS,Les Hopitaux Robert Schuman - Hopital Kirchberg,hopital
|
||||
CHNP,Centre Hospitalier Neuro-Psychiatrique,hopital
|
||||
CHDN,Centre hospitalier du Nord,hopital
|
||||
Police,Police Grand-Ducal,sécurité
|
||||
CGDIS,Corps Grand-Ducal d'incendie et de Secours,sécurité
|
||||
CIGL,Centre Initiative et de Gestion Locale,emploi
|
||||
SCAS,Service Central d'Assistance Sociale,justice
|
||||
ONE,Office National de l'Enfance,enfance
|
||||
ONA,Office National de l'Accueil,immigration
|
||||
Lisko,Letzebuerger Integratiouns - a sozialkohäsiounszenter,immigration
|
||||
Aris,Agents régionaux d'inclusion sociale,emploi
|
||||
ONIS,Office National d'inclusion sociale,emploi
|
||||
ADEM,Agence pour le développement de l'emploi,emploi
|
||||
FNS,Fonds National de Solidarité,aide sociale
|
||||
CCSS,Centre Commun de la Sécurité Sociale,Santé
|
||||
CNS,Centre National de la Santé,Santé
|
||||
MiSa,Ministère de la Santé et de la Sécurité Sociale,Ministère
|
||||
MAI,Ministère des Affaires Intérieures,Ministère
|
||||
MAE,Ministère des Affaires Etrangères et Européennes,Ministère
|
||||
CLAE,Comité de Liaison des Associations d'Etranger,immigration
|
||||
ASTI,Association de Soutien aux Travailleurs Immigrés,immigration
|
||||
Croix-rouge luxembourgeoise,Croix-rouge luxembourgeoise,aide sociale
|
||||
HUT asbl,Hëllef Um Terrain ,aide sociale
|
||||
Inter-actions,Inter-actions,aide sociale
|
||||
Office sociaux,Office sociaux,aide sociale
|
||||
MdM,Médecins du Monde,Santé
|
||||
JDH,Jügend- an Drogenhellef,toxicologie
|
||||
Maison Escale,Maison Escale,Santé
|
||||
CNDS,Comité National de Défense Sociale,aide sociale
|
||||
Streetwork,Streetwork,aide sociale
|
||||
SePAS,Service Psycho-social et d'accompagnements scolaires,enfance
|
||||
WAK,Wanteraktioun,aide sociale
|
||||
Aide au logement,Aide au logement,logement
|
||||
Fonds du Logement,Fonds du Logement,logement
|
||||
SNHBM,Société National des Habitations à Bon Marché,logement
|
||||
Service logement communal,Service logement communal,logement
|
||||
Ennerdach asbl,Ennerdach asbl,logement
|
||||
Arcus,Arcus,aide sociale
|
||||
Quai57,Quai57,toxicologie
|
||||
AIS,Agence Immobilière Sociale,logement
|
||||
AIS-Kordall,Agence immobilière Sociale - Kordall,logement
|
||||
Log-IN,Log-IN,aide sociale
|
||||
Ombudsman,Ombudsman,justice
|
||||
OKAJU,Ombudsman fir Kanner a JugenIecher,justice
|
||||
Gutt Wunnen,Gutt Wunnen,logement
|
||||
Abrigado,Abrigado,toxicologie
|
||||
Life asbl,Life asbl,logement
|
||||
MiLo,Ministère du Logement et de l'aménagement du territoire ,Ministère
|
||||
FDL,Fond du Logement,logement
|
||||
Barreau de Luxembourg,Barreau de Luxembourg,justice
|
||||
Consulat,Consulat,Consulat
|
||||
Ambassade,Ambassade,Ambassade
|
||||
Administration de contribution directe,Administration de contribution directe,fiscalité
|
||||
SNAS,Service National D'Action Sociale,Ministère
|
||||
Alan - Maladies Rares Luxembourg,Alan - Maladies Rares Luxembourg,Santé
|
||||
Oméga 90,Oméga 90,Santé
|
||||
|
29
csv_stemm/choix_usagers.csv
Normal file
29
csv_stemm/choix_usagers.csv
Normal file
@@ -0,0 +1,29 @@
|
||||
civility,lastname,firstname,gender,gendercomment,nationality,memo,birthdate,place_of_birth,countryofbirth,deathdate,email,phonenumber,mobilenumber,contactinfo,street,extra,streetnumber,postcode,country
|
||||
Monsieur,Barbosa De Freitas,Jorge,Homme,,Portugal,,27/02/1974,,,,,691823643,,,Avenue Parc Sports,2ème étage,47,L-4671,Luxembourg
|
||||
Monsieur,Clement,Patrick,Homme,,Luxembourg,,09/01/1980,,,,,661326035,,,rue Jean Gallion,2ème étage,53,L-4569,Luxembourg
|
||||
Monsieur,Bifsa,Alexanter,Homme,,Grèce,,27/10/1968,,,,,691568014,,,rue des Etats-Unis,2ème étage,40,L-1477,Luxembourg
|
||||
Monsieur,Schanen,Patrick,Homme,,Luxembourg,,18/01/1965,,,,,691237244,,,rue des Etats-Unis,2ème étage,40,L-1477,Luxembourg
|
||||
Monsieur,Ramalho Flores,Alexandre,Homme,,Portugal,,10/08/1983,,,,,661838358,,,rue de Merl,3ème étage,83,L-2146,Luxembourg
|
||||
Madame,Debesay Ghebreyesus,Kesanet,Femme,,Erythrée,,01/01/1995,,,,,661351725,,,rue Gare-Usine,1er étage,44,L-3481,Luxembourg
|
||||
Monsieur,Castro e Sousa Coelho Da Rocha,Joao Henriques,Homme,,Portugal,,18/11/1964,,,,,691893614,,,rue Gare-Usine,rez-de-chaussée,44,L-3481,Luxembourg
|
||||
Monsieur,Fettes,André,Homme,,Luxembourg,,11/04/1983,,,,,691584045,,,rue de l'Ecole,3ème étage,27,L-4103,Luxembourg
|
||||
Madame,Thibault,Véronique,Femme,,France,,19/06/1974,,,,,661798327,,,place Saint Michel,3ème étage,9,L-4242,Luxembourg
|
||||
Monsieur,Ramdedovic,Muslija,Homme,,Monténégro,,01/10/1971,,,,,691573447,,,rue Jean-Pierre Theisen,rez-de-chaussée,1,L-4331,Luxembourg
|
||||
Monsieur,De Pina Fortes,Carlos,Homme,,Luxembourg,Portugal,06/12/1978,,,,,691781278,,,rue Saint Vincent,rez-de-chaussée,13,L-4344,Luxembourg
|
||||
Madame,Da Cruz Monteiro,Laise Telma,Femme,,Luxembourg,,10/10/1992,,,,,691594836,,,rue de la fenderie,rez-de-chaussée,1B,L-3734,Luxembourg
|
||||
Madame,Ratinet,Magali,Femme,,France,,09/05/1973,,,,,661389224,,,rue de la fenderie,rez-de-chaussée,1A,L-3734,Luxembourg
|
||||
Monsieur,Wahl,Claude,Homme,,Luxembourg,,19/08/1961,,,,,621476607,,,op der Nuddelsfabrik,1er étage,5,L-3424,Luxembourg
|
||||
Monsieur,Cantarella,David,Homme,,Belge,,26/05/1973,,,,,691300834,,,rue du Clopp,1er étage,2B,L-4810,Luxembourg
|
||||
Monsieur,Muno,Patrick,Homme,,Luxembourg,,27/01/1970,,,,,691197050,,,route d'Esch,1er étage,32,L-4450,Luxembourg
|
||||
Monsieur,Oliveira Rodrigues,Nelson,Homme,,Cap-Vert,,29/12/1976,,,,,621635212,,,route d'Esch,2ème étage,32,L-4450,Luxembourg
|
||||
Monsieur,Taborda Ribeiro,Daniel,Homme,,Portugal,,23/04/1963,,,,,691595218,,,route d'Esch,2ème étage,32,L-4450,Luxembourg
|
||||
Madame,Monteiro,Ana Maria,Femme,,Portugal,,20/12/1961,,,,,621644070,,,rue Jean Schortgen,1er étage (arrière),2,L-3787,Luxembourg
|
||||
Monsieur,Cordovado,Daniel,Homme,,Luxembourg,,24/01/1972,,,,,621561597,,,rue Jean Schortgen,1er étage (avant),2,L-3787,Luxembourg
|
||||
Monsieur,Hasan,Hashim Abdullah Hasan,Homme,,Irak,,01/06/1985,,,,,661474629,,,rue Jean Schortgen,2ème étage (arrière),2,L-3787,Luxembourg
|
||||
Madame,Marques Da Costa,Maria Isaura,Femme,,Portugal,,24/12/1957,,,,,621528040,,,rue Jean Schortgen,2ème étage (avant),2,L-3787,Luxembourg
|
||||
Monsieur,De Oilveira Campos Pereira,Antonio Carlos,Homme,,Portugal,,01/10/1958,,,,,661718315,,,rue Jean Schortgen,3ème étage,2,L-3787,Luxembourg
|
||||
Madame,Stoffel,Marie-Jeanne,Femme,,Luxembourg,,12/03/1961,,,,,621764613,,,rue de Mâcon,1er étage,81,L-4230,Luxembourg
|
||||
Monsieur,Brack,Francis,Homme,,Luxembourg,,28/05/1980,,,,,621573872,,,op der Léier,1er étage,4,L-4240,Luxembourg
|
||||
Monsieur,Moreira Soares,José Augusto,Homme,,Portugal,,17/10/1968,,,,,621765741,,,op der Léier,rez-de-chaussée,5,L-4240,Luxembourg
|
||||
Madame,Oskan,Laila,Femme,,Luxembourg,,03/02/1990,,,,,621599566,,,rue de l'Avenir,rez-de-chaussée,38,L-1147,Luxembourg
|
||||
Monsieur,Benamtar,Ilies-Saïd,Homme,,Algérie,,09/05/1988,,,,,691225092,,,rue de l'Ecole,1er étage,6,L-7410,Luxembourg
|
||||
|
146
csv_stemm/periodes.csv
Normal file
146
csv_stemm/periodes.csv
Normal file
@@ -0,0 +1,146 @@
|
||||
id,nom,openingdate,closingdate,closingmotive,origin,remark,intensity,referrer,job,acp_scopes,address,personlocation,addresslocation,acp_socialissues,work_socialaction,comment1_content,comment2_content,comment3_content,comment4_content,comment5_content
|
||||
1,Periode 1,,,,,,,,,,,,,Santé > Accès aux soins,"Ecouter, informer, conseiller",,,,,
|
||||
2,Periode 2,,,,,,,,,,,,,Santé > Accès aux soins,Orienter vers une structure compétente,,,,,
|
||||
3,Periode 3,,,,,,,,,,,,,Santé > Accès aux soins,vérifier droits d'accès,,,,,
|
||||
4,Periode 4,,,,,,,,,,,,,Santé > Accès aux soins,affiliation volontaire,,,,,
|
||||
5,Periode 5,,,,,,,,,,,,,Santé > Accès aux soins,Orienter vers OS (pour prise en charge de l'affiliation volontaire et/ou tiers payant),,,,,
|
||||
6,Periode 6,,,,,,,,,,,,,Santé > Accès aux soins,projet CUSS,,,,,
|
||||
7,Periode 7,,,,,,,,,,,,,Santé > Accès aux soins,Prévention et Sensibilisation,,,,,
|
||||
8,Periode 8,,,,,,,,,,,,,Santé > Accès aux soins,"Rédaction recours (CNS, Médecin contrôle,...)",,,,,
|
||||
9,Periode 9,,,,,,,,,,,,,Santé > Accès aux soins,prise en charge de facture médicale ou autre,,,,,
|
||||
10,Periode 10,,,,,,,,,,,,,Santé > Accès aux soins,"Réorienter chez médecin gratuit (Médecins du Monde, Stëmm vun der Strooss)",,,,,
|
||||
11,Periode 11,,,,,,,,,,,,,Santé > Accès aux soins,Demande assistance dépendance,,,,,
|
||||
12,Periode 12,,,,,,,,,,,,,Santé > Santé mentale,"Ecouter, informer, conseiller",,,,,
|
||||
13,Periode 13,,,,,,,,,,,,,Santé > Santé mentale,Prise de rendez-vous médicaux,,,,,
|
||||
14,Periode 14,,,,,,,,,,,,,Santé > Santé mentale,Réorientation service compétent,,,,,
|
||||
15,Periode 15,,,,,,,,,,,,,Santé > Consultation médicale – Stëmm,enquête Dr Stëmm,,,,,
|
||||
16,Periode 16,,,,,,,,,,,,,Santé > Consultation médicale – Stëmm,"établir une prise en charge pour spécialiste, laboratoire, radiologie,...",,,,,
|
||||
17,Periode 17,,,,,,,,,,,,,Santé > Consultation médicale – Stëmm,établir un bon pharmacie,,,,,
|
||||
18,Periode 18,,,,,,,,,,,,,Santé > Consultation médicale – Stëmm,prise en charge de facture médicale ou autre,,,,,
|
||||
19,Periode 19,,,,,,,,,,,,,Santé > Handicap,"Ecouter, informer, conseiller",,,,,
|
||||
20,Periode 20,,,,,,,,,,,,,Santé > Handicap,Prise de rendez-vous médicaux,,,,,
|
||||
21,Periode 21,,,,,,,,,,,,,Santé > Handicap,Réorientation service compétent,,,,,
|
||||
22,Periode 22,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),"Ecouter, informer, conseiller",,,,,
|
||||
23,Periode 23,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Enquête sociale,,,,,
|
||||
24,Periode 24,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Préparation de la demande,,,,,
|
||||
25,Periode 25,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Transmission de la demande au Ministère de la Santé,,,,,
|
||||
26,Periode 26,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),"Echange avec MISA, CCSS, CNS",,,,,
|
||||
27,Periode 27,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Entretien régulier,,,,,
|
||||
28,Periode 28,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Prise de rendez-vous médicaux,,,,,
|
||||
29,Periode 29,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Demande assistance dépéndance,,,,,
|
||||
30,Periode 30,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Accompagnement physique au rendez-vous,,,,,
|
||||
31,Periode 31,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Suivi social,,,,,
|
||||
32,Periode 32,,,,,,,,,,,,,Santé > CUSS (Couverture Universelle des Soins de Santé),Art. 32,,,,,
|
||||
33,Periode 33,,,,,,,,,,,,,Justice > Accès aux droits,Enquête sociale,,,,,
|
||||
34,Periode 34,,,,,,,,,,,,,Justice > Accès aux droits,Vérifier les possibilités d'accès aux droits,,,,,
|
||||
35,Periode 35,,,,,,,,,,,,,Justice > Accès aux droits,aide à la constitution d'un dossier pour l'OS ou autre,,,,,
|
||||
36,Periode 36,,,,,,,,,,,,,Justice > Accès aux droits,Vérifier possibilité d'une adresse,,,,,
|
||||
37,Periode 37,,,,,,,,,,,,,Justice > Accès aux droits,Vérifier si autorisation de travailler,,,,,
|
||||
38,Periode 38,,,,,,,,,,,,,Justice > Accès aux droits,"Informer, conseiller, expliquer",,,,,
|
||||
39,Periode 39,,,,,,,,,,,,,Justice > Accès aux droits,Orienter vers réseau (bas seuil ou spécialisé dans la problématique),,,,,
|
||||
40,Periode 40,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Enquête sociale,,,,,
|
||||
41,Periode 41,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Vérifier les possibilités d'accès aux droits,,,,,
|
||||
42,Periode 42,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Vérifier possibilité d'une adresse,,,,,
|
||||
43,Periode 43,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Vérifier si autorisation de travailler,,,,,
|
||||
44,Periode 44,,,,,,,,,,,,,Justice > Accès aux droits – Migration,"Informer, conseiller",,,,,
|
||||
45,Periode 45,,,,,,,,,,,,,Justice > Accès aux droits – Migration,"Orienter vers réseau (ASTI, CLAE, HUT, LISKO, ONA...)",,,,,
|
||||
46,Periode 46,,,,,,,,,,,,,Justice > Accès aux droits – Migration,(Renouvellement) titre de séjour,,,,,
|
||||
47,Periode 47,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Actualisation documents d'identité,,,,,
|
||||
48,Periode 48,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Contacter MAI,,,,,
|
||||
49,Periode 49,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Contacter MAE,,,,,
|
||||
50,Periode 50,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Assistance judiciaire (recours),,,,,
|
||||
51,Periode 51,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Centre de rétention/Maison retour,,,,,
|
||||
52,Periode 52,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Retour volontaire (IOM),,,,,
|
||||
53,Periode 53,,,,,,,,,,,,,Justice > Accès aux droits – Migration,Regroupement familial,,,,,
|
||||
54,Periode 54,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,Demande d'assistance judiciaire,,,,,
|
||||
55,Periode 55,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,Réorientation permanence judiciaire gratuite,,,,,
|
||||
56,Periode 56,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,"recherche de renseignements concernant l'affaire (police, avocat, parquet,..)",,,,,
|
||||
57,Periode 57,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,Ombudsman/OKAJU,,,,,
|
||||
58,Periode 58,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,"Demande renseignement service spécialisé (Mieterschutz, UCL, Syndicats,...)",,,,,
|
||||
59,Periode 59,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,Explication courrier,,,,,
|
||||
60,Periode 60,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,Rédaction recours,,,,,
|
||||
61,Periode 61,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,Echange services pénitentiaires,,,,,
|
||||
62,Periode 62,,,,,,,,,,,,,Justice > Accès aux droits – Juridique,"Contact service compétent (avocat, huissier, créanciers,...)",,,,,
|
||||
63,Periode 63,,,,,,,,,,,,,Justice > Protection Adulte,"Ecouter, informer, conseiller",,,,,
|
||||
64,Periode 64,,,,,,,,,,,,,Justice > Protection Adulte,"Prise de contact service compétent (violence.lu, SCAS,...)",,,,,
|
||||
65,Periode 65,,,,,,,,,,,,,Justice > Protection Adulte,"Réorientation service compétent (violence.lu, SCAS,...)",,,,,
|
||||
66,Periode 66,,,,,,,,,,,,,Justice > Protection Adulte,Réorientation Police (Plainte),,,,,
|
||||
67,Periode 67,,,,,,,,,,,,,Justice > Protection Adulte,Réorientation Service Info Traite,,,,,
|
||||
68,Periode 68,,,,,,,,,,,,,Justice > Protection Adulte,Demande d'assistance judiciaire,,,,,
|
||||
69,Periode 69,,,,,,,,,,,,,Justice > Protection Adulte – besoins spécifiques,"Ecouter, informer, conseiller",,,,,
|
||||
70,Periode 70,,,,,,,,,,,,,Justice > Protection Adulte – besoins spécifiques,"Réorientation service compétent (TACS, Avocat,...)",,,,,
|
||||
71,Periode 71,,,,,,,,,,,,,Justice > Protection Adulte – besoins spécifiques,Faire une demande tutelle/curatelle,,,,,
|
||||
72,Periode 72,,,,,,,,,,,,,Emploi > Sans emploi,"Informer, conseiller, expliquer",,,,,
|
||||
73,Periode 73,,,,,,,,,,,,,Emploi > Sans emploi,Rédaction de CV,,,,,
|
||||
74,Periode 74,,,,,,,,,,,,,Emploi > Sans emploi,Rédaction de LM,,,,,
|
||||
75,Periode 75,,,,,,,,,,,,,Emploi > Sans emploi,Réorientation vers ACT ou similaire,,,,,
|
||||
76,Periode 76,,,,,,,,,,,,,Emploi > Sans emploi,Intérim,,,,,
|
||||
77,Periode 77,,,,,,,,,,,,,Emploi > Sans emploi,Inscription Adem,,,,,
|
||||
78,Periode 78,,,,,,,,,,,,,Emploi > problèmes,"Ecouter, informer, conseiller",,,,,
|
||||
79,Periode 79,,,,,,,,,,,,,Emploi > problèmes,Echange employeur,,,,,
|
||||
80,Periode 80,,,,,,,,,,,,,Emploi > problèmes,Echange ONIS,,,,,
|
||||
81,Periode 81,,,,,,,,,,,,,Emploi > problèmes,Echange ARIS,,,,,
|
||||
82,Periode 82,,,,,,,,,,,,,Emploi > problèmes,Contact ITM,,,,,
|
||||
83,Periode 83,,,,,,,,,,,,,Emploi > problèmes,Rédaction courrier,,,,,
|
||||
84,Periode 84,,,,,,,,,,,,,Emploi > problèmes,Réorientation Service Info Traite,,,,,
|
||||
85,Periode 85,,,,,,,,,,,,,Emploi > ISP (TUC où autre),Echange avec ADEM,,,,,
|
||||
86,Periode 86,,,,,,,,,,,,,Emploi > ISP (TUC où autre),Echange avec employeur,,,,,
|
||||
87,Periode 87,,,,,,,,,,,,,Emploi > ISP (TUC où autre),Réorienter vers l'ONIS,,,,,
|
||||
88,Periode 88,,,,,,,,,,,,,Emploi > ISP (TUC où autre),Echanger avec l'ARIS,,,,,
|
||||
89,Periode 89,,,,,,,,,,,,,Finance > Guidance budgétaire,"Ecouter, informer, conseiller",,,,,
|
||||
90,Periode 90,,,,,,,,,,,,,Finance > Guidance budgétaire,Signer la procuration,,,,,
|
||||
91,Periode 91,,,,,,,,,,,,,Finance > Guidance budgétaire,Signer la dénonciation de procuration,,,,,
|
||||
92,Periode 92,,,,,,,,,,,,,Finance > Guidance budgétaire,Faire un bilan de la situation financière,,,,,
|
||||
93,Periode 93,,,,,,,,,,,,,Finance > Guidance budgétaire,Etablir un plan budgétaire ou d'apurement,,,,,
|
||||
94,Periode 94,,,,,,,,,,,,,Finance > Guidance budgétaire,Réévaluation en cas de besoin,,,,,
|
||||
95,Periode 95,,,,,,,,,,,,,Finance > Guidance budgétaire,"Contacter les créanciers, huissiers,...",,,,,
|
||||
96,Periode 96,,,,,,,,,,,,,Finance > Guidance budgétaire,aide à la constitution d'un dossier pour l'OS,,,,,
|
||||
97,Periode 97,,,,,,,,,,,,,Finance > Guidance budgétaire,Ouvrir un compte bancaire,,,,,
|
||||
98,Periode 98,,,,,,,,,,,,,Finance > Guidance budgétaire,Clôturer un compte bancaire,,,,,
|
||||
99,Periode 99,,,,,,,,,,,,,Finance > Guidance budgétaire,Effectuer un virement,,,,,
|
||||
100,Periode 100,,,,,,,,,,,,,Finance > Guidance budgétaire,Donner de l'argent liquide,,,,,
|
||||
101,Periode 101,,,,,,,,,,,,,Finance > Guidance budgétaire,Accès aide alimentaire,,,,,
|
||||
102,Periode 102,,,,,,,,,,,,,Finance > Guidance budgétaire,mise en place d'ordres permanents,,,,,
|
||||
103,Periode 103,,,,,,,,,,,,,Finance > Guidance budgétaire,faire une avance,,,,,
|
||||
104,Periode 104,,,,,,,,,,,,,Finance > Guidance budgétaire,"vérifier les possibilités d'accès (Revis, Rpgh, chômage, pension, invalidité,allocations familiales...)",,,,,
|
||||
105,Periode 105,,,,,,,,,,,,,Finance > Guidance budgétaire,entamer les démarches requises,,,,,
|
||||
106,Periode 106,,,,,,,,,,,,,Finance > Guidance budgétaire,"rédiger un recours (ADEM, FNS,...)",,,,,
|
||||
107,Periode 107,,,,,,,,,,,,,Logement > Accès au logement,"Ecouter, informer, conseiller",,,,,
|
||||
108,Periode 108,,,,,,,,,,,,,Logement > Accès au logement,Faire demande RENLA,,,,,
|
||||
109,Periode 109,,,,,,,,,,,,,Logement > Accès au logement,Faire une demande de subvention loyer,,,,,
|
||||
110,Periode 110,,,,,,,,,,,,,Logement > Accès au logement,Faire une demande d'aide pour garanti locative de l'état,,,,,
|
||||
111,Periode 111,,,,,,,,,,,,,Logement > Accès au logement,Orienter vers OS pour garantie locative,,,,,
|
||||
112,Periode 112,,,,,,,,,,,,,Logement > Accès au logement,Faire un recours en cas de notification de déguerpissement,,,,,
|
||||
113,Periode 113,,,,,,,,,,,,,Logement > Accès au logement,Orienter vers logement d'urgence,,,,,
|
||||
114,Periode 114,,,,,,,,,,,,,Logement > perte/absence,"Ecouter, informer, conseiller",,,,,
|
||||
115,Periode 115,,,,,,,,,,,,,Logement > perte/absence,Réorientation vers office social,,,,,
|
||||
116,Periode 116,,,,,,,,,,,,,Logement > perte/absence,Demande d'adresse de référence,,,,,
|
||||
117,Periode 117,,,,,,,,,,,,,Logement > perte/absence,Demande RENLA,,,,,
|
||||
118,Periode 118,,,,,,,,,,,,,Logement > perte/absence,Demande logements sociaux,,,,,
|
||||
119,Periode 119,,,,,,,,,,,,,Logement > perte/absence,Orientation pour adresse courrier,,,,,
|
||||
120,Periode 120,,,,,,,,,,,,,Logement > perte/absence,Orientation structure d'urgence,,,,,
|
||||
121,Periode 121,,,,,,,,,,,,,Logement > perte/absence,faire une demande pour maison de repos \ maison de soins,,,,,
|
||||
122,Periode 122,,,,,,,,,,,,,Logement > perte/absence,actualisation annuelle de la demande logement social,,,,,
|
||||
123,Periode 123,,,,,,,,,,,,,Logement > perte/absence,actualisation subvention loyer,,,,,
|
||||
124,Periode 124,,,,,,,,,,,,,Logement > Adresse de référence,Enquête sociale (vérifier les conditions d'accès),,,,,
|
||||
125,Periode 125,,,,,,,,,,,,,Logement > Adresse de référence,Instruction de la demande,,,,,
|
||||
126,Periode 126,,,,,,,,,,,,,Logement > Adresse de référence,Réorientation vers service compétent,,,,,
|
||||
127,Periode 127,,,,,,,,,,,,,Logement > Adresse de référence,Accompagnement social,,,,,
|
||||
128,Periode 128,,,,,,,,,,,,,Logement > Adresse de référence,Clôture de la demande,,,,,
|
||||
129,Periode 129,,,,,,,,,,,,,Logement > Logement Encadré,Entretien d'évaluation (avant déménagement),,,,,
|
||||
130,Periode 130,,,,,,,,,,,,,Logement > Logement Encadré,Rédiger contrat avec objectifs à atteindre,,,,,
|
||||
131,Periode 131,,,,,,,,,,,,,Logement > Logement Encadré,Visites régulières,,,,,
|
||||
132,Periode 132,,,,,,,,,,,,,Logement > Logement Encadré,"Aides démarches (administratives, quotidiens, etc)",,,,,
|
||||
133,Periode 133,,,,,,,,,,,,,Logement > Logement Encadré,Si objectifs atteint -> sortie logement,,,,,
|
||||
134,Periode 134,,,,,,,,,,,,,Logement > Logement Encadré,échange avec bailleur social,,,,,
|
||||
135,Periode 135,,,,,,,,,,,,,Logement > Logement Encadré,compléter révision annuelle du loyer,,,,,
|
||||
136,Periode 136,,,,,,,,,,,,,Logement > Insalubrité,"Ecouter, informer, conseiller",,,,,
|
||||
137,Periode 137,,,,,,,,,,,,,Logement > Insalubrité,Chercher le dialogue avec le bailleur,,,,,
|
||||
138,Periode 138,,,,,,,,,,,,,Logement > Insalubrité,Echange Mairie,,,,,
|
||||
139,Periode 139,,,,,,,,,,,,,Logement > Insalubrité,Echange centre d'hébergement,,,,,
|
||||
140,Periode 140,,,,,,,,,,,,,Logement > Insalubrité,Procédure d'insalubrité,,,,,
|
||||
141,Periode 141,,,,,,,,,,,,,Logement > Insalubrité,Rédaction de recours,,,,,
|
||||
142,Periode 142,,,,,,,,,,,,,Logement > Insalubrité,Echange avocat,,,,,
|
||||
143,Periode 143,,,,,,,,,,,,,Logement > médiation,Echange avec Bailleur,,,,,
|
||||
144,Periode 144,,,,,,,,,,,,,Logement > médiation,Echange Mairie,,,,,
|
||||
145,Periode 145,,,,,,,,,,,,,Logement > médiation,Echange centre d'hébergement,,,,,
|
||||
|
125
import_all_csv.sh
Executable file
125
import_all_csv.sh
Executable file
@@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
DB_HOST="${PGHOST:-localhost}"
|
||||
DB_PORT="${PGPORT:-5432}"
|
||||
DB_USER="${PGUSER:-postgres}"
|
||||
DB_NAME="${PGDATABASE:-chill-import}"
|
||||
|
||||
PSQL=(psql -v ON_ERROR_STOP=1 -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME")
|
||||
PREPARE_SQL="$ROOT_DIR/sql/prepare-import.sql"
|
||||
|
||||
required_tables=(
|
||||
"import.personnes"
|
||||
"import.periodes"
|
||||
"import.choix_periodes"
|
||||
"import.choix_localisations"
|
||||
"import.tiers"
|
||||
)
|
||||
|
||||
required_files=(
|
||||
"$ROOT_DIR/csv/choix_usagers.csv"
|
||||
"$ROOT_DIR/csv/periodes.csv"
|
||||
"$ROOT_DIR/csv/choix_periodes.csv"
|
||||
"$ROOT_DIR/csv/choix_localisations.csv"
|
||||
"$ROOT_DIR/csv/choix_tiers.csv"
|
||||
)
|
||||
|
||||
if [[ ! -f "$PREPARE_SQL" ]]; then
|
||||
echo "Fichier SQL manquant: ${PREPARE_SQL#$ROOT_DIR/}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[-1/3] Recreation du schema import..."
|
||||
"${PSQL[@]}" -c "DROP SCHEMA IF EXISTS import CASCADE;"
|
||||
"${PSQL[@]}" -f "$PREPARE_SQL"
|
||||
|
||||
for table in "${required_tables[@]}"; do
|
||||
exists="$("${PSQL[@]}" -tAc "SELECT to_regclass('${table}') IS NOT NULL;")"
|
||||
if [[ "$exists" != "t" ]]; then
|
||||
echo "Table manquante: ${table}" >&2
|
||||
echo "Lance d'abord: psql -h ${DB_HOST} -p ${DB_PORT} -U ${DB_USER} -d ${DB_NAME} -f sql/prepare-import.sql" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
for csv_file in "${required_files[@]}"; do
|
||||
if [[ ! -f "$csv_file" ]]; then
|
||||
echo "Fichier CSV manquant: ${csv_file#$ROOT_DIR/}" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "[0/3] Assouplissement des types texte des tables import..."
|
||||
"${PSQL[@]}" <<'SQL'
|
||||
DO $$
|
||||
DECLARE r record;
|
||||
BEGIN
|
||||
FOR r IN
|
||||
SELECT table_schema, table_name, column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'import'
|
||||
AND table_name IN ('personnes', 'periodes', 'choix_periodes', 'choix_localisations', 'tiers')
|
||||
AND data_type IN ('character varying', 'character')
|
||||
LOOP
|
||||
EXECUTE format(
|
||||
'ALTER TABLE %I.%I ALTER COLUMN %I TYPE text',
|
||||
r.table_schema,
|
||||
r.table_name,
|
||||
r.column_name
|
||||
);
|
||||
END LOOP;
|
||||
END $$;
|
||||
SQL
|
||||
|
||||
echo "[1/3] Vidage des tables d'import..."
|
||||
"${PSQL[@]}" <<'SQL'
|
||||
TRUNCATE TABLE
|
||||
import.personnes,
|
||||
import.periodes,
|
||||
import.choix_periodes,
|
||||
import.choix_localisations,
|
||||
import.tiers
|
||||
RESTART IDENTITY;
|
||||
SQL
|
||||
|
||||
echo "[2/3] Import des CSV du dossier csv/..."
|
||||
|
||||
copy_table_from_file() {
|
||||
local table="$1"
|
||||
local file_path="$2"
|
||||
local columns="${3:-}"
|
||||
local target="$table"
|
||||
if [[ -n "$columns" ]]; then
|
||||
target="${table}(${columns})"
|
||||
fi
|
||||
echo " - import ${table} <= ${file_path#$ROOT_DIR/}"
|
||||
"${PSQL[@]}" -c "\\copy ${target} FROM STDIN WITH (FORMAT csv, HEADER true, DELIMITER ',')" < "$file_path"
|
||||
}
|
||||
|
||||
copy_table_from_file "import.personnes" "$ROOT_DIR/csv/choix_usagers.csv" "civility,lastname,firstname,gender,gendercomment,nationality,memo,birthdate,place_of_birth,countryofbirth,deathdate,email,phonenumber,mobilenumber,contactinfo,street,extra,streetnumber,postcode,country"
|
||||
|
||||
echo " - generation des ids manquants dans import.personnes"
|
||||
"${PSQL[@]}" <<'SQL'
|
||||
WITH numbered AS (
|
||||
SELECT ctid, row_number() OVER (ORDER BY ctid) AS new_id
|
||||
FROM import.personnes
|
||||
WHERE id IS NULL OR NULLIF(id::text, '') IS NULL
|
||||
)
|
||||
UPDATE import.personnes p
|
||||
SET id = numbered.new_id
|
||||
FROM numbered
|
||||
WHERE p.ctid = numbered.ctid;
|
||||
SQL
|
||||
|
||||
copy_table_from_file "import.periodes" "$ROOT_DIR/csv/periodes.csv" "id,nom,openingdate,closingdate,closingmotive,origin,remark,intensity,referrer,job,acp_scopes,address,personlocation,addresslocation,acp_socialissues,work_socialaction,comment1_content,comment2_content,comment3_content,comment4_content,comment5_content"
|
||||
copy_table_from_file "import.choix_periodes" "$ROOT_DIR/csv/choix_periodes.csv" "closingmotive,origin,acp_scopes,job,referrer,parent,enfant,acp_social_issues,work_social_action,street,extra,streetnumber,postcode,country"
|
||||
copy_table_from_file "import.choix_localisations" "$ROOT_DIR/csv/choix_localisations.csv" "title,\"addressRequired\",\"availableForUsers\",\"contactData\",\"defaultFor\",\"editableByUsers\""
|
||||
copy_table_from_file "import.tiers" "$ROOT_DIR/csv/choix_tiers.csv" "acronym,nom,categorie"
|
||||
|
||||
echo "[3/3] Verification des volumes importes..."
|
||||
"${PSQL[@]}" -c "SELECT 'personnes' AS table_name, count(*) AS rows FROM import.personnes UNION ALL SELECT 'periodes', count(*) FROM import.periodes UNION ALL SELECT 'choix_periodes', count(*) FROM import.choix_periodes UNION ALL SELECT 'choix_localisations', count(*) FROM import.choix_localisations UNION ALL SELECT 'tiers', count(*) FROM import.tiers;"
|
||||
|
||||
echo "Import termine sans doublons (tables videes au debut)."
|
||||
592
sql/import.sql
Normal file → Executable file
592
sql/import.sql
Normal file → Executable file
@@ -10,6 +10,14 @@
|
||||
-- * referrer: cfr. 57
|
||||
-- * scopes: cfr. 58
|
||||
--
|
||||
-- vérifier les étiquettes de colonnes: user-> referrer, acp_social_issues-> acp_socialissues
|
||||
|
||||
-- Exécution du bloc DOWN uniquement si demandé explicitement:
|
||||
-- psql -v run_down=1 -f sql/import.sql
|
||||
\if :{?run_down}
|
||||
\else
|
||||
\set run_down 0
|
||||
\endif
|
||||
|
||||
|
||||
-- 1. Adjust Type cast for id columns
|
||||
@@ -125,7 +133,7 @@ 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;
|
||||
UPDATE import.choix_periodes SET enfant1=json_build_object('fr', upper(trim(enfant))) WHERE enfant !='';
|
||||
WITH max_ordering AS ( SELECT MAX(ordering) as max_ordering FROM chill_person_social_issue )
|
||||
WITH max_ordering AS ( SELECT COALESCE(MAX(ordering),1) as max_ordering FROM chill_person_social_issue )
|
||||
INSERT INTO chill_person_social_issue (id, parent_id, title, ordering)
|
||||
SELECT nextval('chill_person_social_issue_id_seq'),
|
||||
null, t.parent1,
|
||||
@@ -136,16 +144,69 @@ INSERT INTO chill_person_social_issue (id, parent_id, title, ordering)
|
||||
WITH max_ordering AS ( SELECT MAX(ordering) as max_ordering FROM chill_person_social_issue )
|
||||
INSERT INTO chill_person_social_issue (id, parent_id, title, ordering)
|
||||
SELECT nextval('chill_person_social_issue_id_seq'),
|
||||
( SELECT id FROM chill_person_social_issue WHERE parent_id IS NULL AND title::jsonb->>'fr' = t.parent1::jsonb->>'fr' ), t.enfant1,
|
||||
( SELECT MIN(id) FROM chill_person_social_issue WHERE parent_id IS NULL AND title::jsonb->>'fr' = t.parent1::jsonb->>'fr' ), t.enfant1,
|
||||
max_ordering.max_ordering + row_number() OVER () as ordering
|
||||
FROM ( SELECT DISTINCT ON (acp_socialissues) parent1, enfant1 FROM import.choix_periodes WHERE enfant1 IS NOT NULL ) t
|
||||
FROM ( SELECT DISTINCT ON (acp_social_issues) parent1, enfant1 FROM import.choix_periodes WHERE enfant1 IS NOT NULL ) t
|
||||
CROSS JOIN max_ordering
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM chill_person_social_issue
|
||||
WHERE title::jsonb->>'fr' = t.enfant1::jsonb->>'fr'
|
||||
AND parent_id = (SELECT id FROM chill_person_social_issue WHERE title::jsonb->>'fr' = t.parent1::jsonb->>'fr'));
|
||||
AND parent_id = (SELECT MIN(id) FROM chill_person_social_issue WHERE parent_id IS NULL AND title::jsonb->>'fr' = t.parent1::jsonb->>'fr'));
|
||||
|
||||
-- 14. Complete table WorkSocialActions
|
||||
-- (not yet implemented in canvas)
|
||||
ALTER TABLE import.choix_periodes ADD COLUMN work_social_action1 JSONB;
|
||||
UPDATE import.choix_periodes SET work_social_action1=json_build_object('fr', trim(work_social_action)) WHERE work_social_action!='';
|
||||
ALTER TABLE import.choix_periodes ADD COLUMN work_social_issue1 JSONB;
|
||||
WITH grouped AS (
|
||||
SELECT ctid,
|
||||
SUM(CASE WHEN NULLIF(trim(acp_social_issues), '') IS NOT NULL THEN 1 ELSE 0 END)
|
||||
OVER (ORDER BY ctid) AS grp
|
||||
FROM import.choix_periodes
|
||||
), resolved AS (
|
||||
SELECT cp.ctid,
|
||||
COALESCE(
|
||||
MAX(NULLIF(upper(trim(cp.enfant)), '')) OVER (PARTITION BY g.grp),
|
||||
MAX(NULLIF(upper(trim(cp.parent)), '')) OVER (PARTITION BY g.grp)
|
||||
) AS issue_title
|
||||
FROM import.choix_periodes cp
|
||||
JOIN grouped g ON cp.ctid = g.ctid
|
||||
)
|
||||
UPDATE import.choix_periodes cp
|
||||
SET work_social_issue1 = json_build_object('fr', r.issue_title)
|
||||
FROM resolved r
|
||||
WHERE cp.ctid = r.ctid
|
||||
AND r.issue_title IS NOT NULL
|
||||
AND trim(COALESCE(cp.work_social_action, '')) != '';
|
||||
WITH max_ordering AS ( SELECT COALESCE(MAX(ordering), 0) as max_ordering FROM chill_person_social_action )
|
||||
INSERT INTO chill_person_social_action (id, issue_id, parent_id, desactivationdate, defaultnotificationdelay, title, ordering)
|
||||
SELECT nextval('chill_person_social_action_id_seq'),
|
||||
issue.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
t.work_social_action1,
|
||||
max_ordering.max_ordering + row_number() OVER () as ordering
|
||||
FROM (
|
||||
SELECT DISTINCT ON (work_social_action1, work_social_issue1) work_social_action1, work_social_issue1
|
||||
FROM import.choix_periodes
|
||||
WHERE work_social_action1 IS NOT NULL
|
||||
) t
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT si.id
|
||||
FROM chill_person_social_issue si
|
||||
WHERE si.title::jsonb->>'fr' = t.work_social_issue1::jsonb->>'fr'
|
||||
ORDER BY (si.parent_id IS NULL), si.id
|
||||
LIMIT 1
|
||||
) issue ON true
|
||||
CROSS JOIN max_ordering
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM chill_person_social_action sa
|
||||
WHERE sa.title::jsonb->>'fr' = t.work_social_action1::jsonb->>'fr'
|
||||
AND (
|
||||
(sa.issue_id IS NULL AND issue.id IS NULL)
|
||||
OR sa.issue_id = issue.id
|
||||
)
|
||||
);
|
||||
|
||||
-- 20. Prepare personnes civility
|
||||
ALTER TABLE import.personnes ADD COLUMN civility1 jsonb;
|
||||
@@ -157,7 +218,7 @@ ALTER TABLE import.personnes ADD COLUMN gender1 VARCHAR;
|
||||
UPDATE import.personnes SET gender1 = CASE
|
||||
WHEN trim(gender) IN ('Femme', 'femme', 'Woman', 'woman', 'Female', 'female') THEN 'woman'
|
||||
WHEN trim(gender) IN ('Homme', 'homme', 'Man', 'man', 'Male', 'male') THEN 'man'
|
||||
WHEN trim(gender) IN ('', 'Inconnu', 'inconnu', 'Unknown', 'unknown') THEN 'unknown'
|
||||
WHEN trim(gender) IN ('Autre', 'Inconnu', 'inconnu', 'Unknown', 'unknown') THEN 'unknown'
|
||||
ELSE 'both' END;
|
||||
|
||||
-- 22. Prepare personnes nationality
|
||||
@@ -177,9 +238,17 @@ UPDATE import.personnes SET maritalstatus1=json_build_object('fr', trim(maritals
|
||||
|
||||
-- 25. Prepare personnes numberofchildren
|
||||
ALTER TABLE import.personnes ADD COLUMN numberofchildren1 integer;
|
||||
UPDATE import.personnes SET numberofchildren1=NULLIF(numberofchildren, '')::int;
|
||||
UPDATE import.personnes SET numberofchildren1=NULLIF(numberofchildren, 0)::int;
|
||||
-- SELECT numberofchildren, numberofchildren1 FROM import.personnes;
|
||||
|
||||
-- 25bis. Prepare personnes place_of_birth
|
||||
ALTER TABLE import.personnes ADD COLUMN placeofbirth1 varchar;
|
||||
UPDATE import.personnes SET placeofbirth1=CASE WHEN place_of_birth IS NOT NULL THEN place_of_birth ELSE '' END;
|
||||
|
||||
-- 25ter. Prepare personnes memo
|
||||
ALTER TABLE import.personnes ADD COLUMN memo1 varchar;
|
||||
UPDATE import.personnes SET memo1=CASE WHEN memo IS NOT NULL THEN memo ELSE '' END;
|
||||
|
||||
-- 26. Prepare personnes household_composition_type
|
||||
ALTER TABLE import.personnes ADD COLUMN household_composition_type1 JSONB;
|
||||
UPDATE import.personnes SET household_composition_type1=json_build_object('fr', trim(household_composition_type)) WHERE household_composition_type!='';
|
||||
@@ -219,7 +288,7 @@ ALTER TABLE import.personnes ADD column mobilenumber1 text;
|
||||
ALTER TABLE import.personnes ADD column phonenumber1 text;
|
||||
DO $$
|
||||
DECLARE
|
||||
intl text := 32;
|
||||
intl text := 33;
|
||||
BEGIN
|
||||
-- 33. Format mobile numbers
|
||||
UPDATE import.personnes SET mobilenumber1=NULLIF(regexp_replace(mobilenumber, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||
@@ -251,9 +320,10 @@ UPDATE import.personnes SET person_id=personid
|
||||
INSERT INTO chill_person_person (
|
||||
id
|
||||
, nationality_id, countryofbirth_id, civility_id, maritalstatus_id
|
||||
, firstname, lastname, birthdate, place_of_birth, memo, email, contactinfo, phonenumber, mobilenumber, numberofchildren, gender, deathdate, proxyaccompanyingperiodopenstate
|
||||
, firstname, lastname, birthdate, place_of_birth, memo, email, contactinfo, phonenumber, mobilenumber, numberofchildren, deathdate, proxyaccompanyingperiodopenstate
|
||||
, createdat, updatedat, createdby_id, updatedby_id
|
||||
, center_id
|
||||
, gender_id
|
||||
, gendercomment_comment, gendercomment_userid, gendercomment_date
|
||||
/*
|
||||
, maritalstatusdate
|
||||
@@ -266,10 +336,11 @@ INSERT INTO chill_person_person (
|
||||
, (SELECT c.id FROM country c WHERE c.name::jsonb->>'fr' = ip.countryofbirth1::jsonb->>'fr' AND ip.countryofbirth1 IS NOT NULL ) -- countryofbirth_id,
|
||||
, (SELECT c.id FROM chill_main_civility c WHERE c.name::jsonb->>'fr' = ip.civility1::jsonb->>'fr' AND ip.civility1 IS NOT NULL ) -- civility_id
|
||||
, (SELECT ms.id FROM chill_person_marital_status ms WHERE ms.name::jsonb->>'fr' = ip.maritalstatus1::jsonb->>'fr' AND ip.maritalstatus1 IS NOT NULL ) -- maritalstatus_id,
|
||||
, TRIM(firstname), UPPER(TRIM(lastname)), birthdate1, TRIM(place_of_birth), TRIM(memo), TRIM(email), TRIM(contactinfo), phonenumber1, mobilenumber1, numberofchildren1, gender1, deathdate1, false
|
||||
, COALESCE(TRIM(firstname),''), UPPER(TRIM(lastname)), birthdate1, TRIM(placeofbirth1), TRIM(memo1), TRIM(email), TRIM(contactinfo), phonenumber1, mobilenumber1, numberofchildren1, deathdate1, false
|
||||
, CURRENT_DATE, CURRENT_DATE -- createdat, updatedat (= import date)
|
||||
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users) -- createdby_id, updatedby_id
|
||||
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM centers) -- center_id
|
||||
, NULL -- center_id should be null, deprecated by chill_person_person_center_history
|
||||
, (SELECT g.id FROM chill_main_gender g WHERE g.gendertranslation = ip.gender1)
|
||||
, TRIM(gendercomment), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), date(date_trunc('year', CURRENT_DATE)) --gendercomment_<comment|userid|date>
|
||||
/*
|
||||
, -- maritalstatusdate
|
||||
@@ -288,16 +359,62 @@ INSERT INTO chill_person_person_center_history (id, person_id, center_id, startd
|
||||
-- SELECT ip.id, ip.lastname, ip.firstname, ip.person_id, hist.id, hist.person_id, hist.center_id, hist.startdate, p.id, p.fullnamecanonical, p.email FROM chill_person_person p RIGHT JOIN import.personnes ip ON ip.person_id = p.id FULL JOIN chill_person_person_center_history hist on p.id = hist.person_id ORDER BY ip.person_id;
|
||||
|
||||
-- 43. Add address, and link it to person
|
||||
-- a) add new columns
|
||||
ALTER TABLE import.personnes ADD column address_id BIGINT;
|
||||
ALTER TABLE import.personnes ADD column address_ref_id BIGINT;
|
||||
ALTER TABLE import.personnes ADD column postcode_arr BIGINT[];
|
||||
|
||||
-- special command to extract postcode values in text
|
||||
ALTER TABLE import.personnes ADD COLUMN postcode1 TEXT;
|
||||
UPDATE import.personnes
|
||||
SET postcode1 = NULLIF(regexp_replace(coalesce(postcode, ''), '\D', '', 'g'), '')
|
||||
WHERE coalesce(postcode, '') != '';
|
||||
|
||||
-- b) find and add postal code references. Check missing correspondances (if you can)
|
||||
UPDATE import.personnes
|
||||
SET postcode_arr = (
|
||||
SELECT array_agg(pc.id)
|
||||
FROM chill_main_postal_code AS pc
|
||||
WHERE pc.code = import.personnes.postcode1
|
||||
AND pc.origin = 0
|
||||
);
|
||||
--SELECT * FROM import.personnes as ip WHERE ip.postcode_arr IS NULL -- missing correspondances
|
||||
|
||||
-- c) find and add reference addresses. Check missing correspondances (if you can)
|
||||
UPDATE import.personnes AS ip SET address_ref_id = cmar.id FROM chill_main_address_reference AS cmar
|
||||
WHERE
|
||||
cmar.postcode_id = ANY(ip.postcode_arr)
|
||||
AND similarity(trim(ip.street), trim(cmar.street)) > 0.6
|
||||
AND trim(ip.streetnumber) = trim(cmar.streetnumber);
|
||||
--SELECT * FROM import.personnes as ip WHERE ip.address_ref_id IS NULL -- missing correspondances
|
||||
|
||||
-- d) fill new chill address
|
||||
UPDATE import.personnes SET address_id = nextval('chill_main_address_id_seq');
|
||||
ALTER TABLE import.personnes ADD column postcode_id BIGINT;
|
||||
UPDATE import.personnes SET postcode_id = pc.id FROM chill_main_postal_code pc WHERE pc.code = postcode AND pc.origin = 0;
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom) SELECT
|
||||
address_id, postcode_id, street, streetnumber, extra, COALESCE(validfrom1 , date(date_trunc('year', CURRENT_DATE)))
|
||||
FROM import.personnes WHERE postcode_id IS NOT NULL;
|
||||
|
||||
-- e) insert reference address into chill_main_addresses
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom, addressreference_id, refstatus, point, createdat, updatedat, createdby_id, updatedby_id)
|
||||
SELECT address_id, postcode_arr[1], street, coalesce(streetnumber, ''), coalesce(extra,''),
|
||||
CURRENT_DATE,
|
||||
address_ref_id, 'match',
|
||||
(SELECT point FROM chill_main_address_reference WHERE id = address_ref_id),
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)
|
||||
FROM import.personnes WHERE address_ref_id IS NOT NULL;
|
||||
|
||||
-- f) insert created addresses in chill_main_addresses
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom, point, createdat, updatedat, createdby_id, updatedby_id)
|
||||
SELECT address_id, postcode_arr[1], coalesce(street, ''), coalesce(streetnumber, ''), coalesce(extra,''),
|
||||
CURRENT_DATE,
|
||||
(SELECT center FROM chill_main_postal_code WHERE id = postcode_arr[1]), -- geolocation is given by the postcode
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)
|
||||
FROM import.personnes WHERE address_ref_id IS NULL AND postcode_arr IS NOT NULL;
|
||||
|
||||
SELECT setval('chill_main_address_id_seq', (SELECT COALESCE(max(id)) FROM chill_main_address));
|
||||
-- SELECT ip.person_id, ip.address_id FROM import.personnes ip ;
|
||||
-- SELECT ip.id, ip.person_id, ip.firstname, ip.lastname, addr.* FROM chill_main_address addr RIGHT JOIN import.personnes ip ON addr.id = ip.address_id ORDER BY ip.id;
|
||||
|
||||
-- 44. Add houshold and household member with position
|
||||
INSERT INTO chill_person_household (id) SELECT person_id from import.personnes;
|
||||
@@ -311,7 +428,7 @@ INSERT INTO chill_person_household_members (id, person_id, household_id, startda
|
||||
|
||||
-- 45. Link address to household
|
||||
INSERT INTO chill_person_household_to_addresses (household_id, address_id) SELECT person_id, address_id
|
||||
FROM import.personnes WHERE postcode_id IS NOT NULL; -- cfr (*) adresse insérées seulement si postcode
|
||||
FROM import.personnes WHERE address_id IS NOT NULL AND postcode_arr[1] IS NOT NULL;
|
||||
|
||||
-- 46. Add household composition
|
||||
INSERT INTO chill_person_household_composition (id, household_id, startdate, householdcompositiontype_id) SELECT
|
||||
@@ -332,7 +449,7 @@ UPDATE import.periodes SET period_id = periodid
|
||||
INSERT INTO chill_person_accompanying_period (id, openingdate, closingdate, step, remark, intensity, createdby_id, createdat, updatedby_id, updatedat) SELECT
|
||||
period_id,
|
||||
COALESCE(openingdate1, date(date_trunc('year', CURRENT_DATE))), closingdate1,
|
||||
'CONFIRMED', COALESCE(TRIM(remark), ''), intensity1,
|
||||
'CONFIRMED', COALESCE(TRIM(remark::text), ''), intensity1,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), CURRENT_DATE
|
||||
FROM import.periodes;
|
||||
@@ -346,7 +463,7 @@ INSERT INTO chill_person_accompanying_period_participation (id, person_id, accom
|
||||
-- 53. Prepare temporary address location
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, validFrom) SELECT
|
||||
nextval('chill_main_address_id_seq'),
|
||||
(SELECT pc.id FROM chill_main_postal_code pc WHERE pc.code = postcode),
|
||||
(SELECT pc.id FROM chill_main_postal_code pc WHERE pc.code::int = postcode::int),
|
||||
street, streetnumber, date(date_trunc('year', CURRENT_DATE))
|
||||
FROM import.choix_periodes WHERE street != '';
|
||||
ALTER TABLE import.choix_periodes ADD COLUMN address_location_id BIGINT;
|
||||
@@ -374,36 +491,88 @@ INSERT INTO chill_person_accompanying_period_location_history (id, period_id, st
|
||||
INSERT INTO chill_person_accompanying_period_social_issues (accompanyingperiod_id, socialissue_id)
|
||||
SELECT
|
||||
DISTINCT ON (t.period_id) t.period_id,
|
||||
COALESCE(
|
||||
t.enfant_id,
|
||||
t.parent_id,
|
||||
1 -- default value ?
|
||||
) AS socialissue_id
|
||||
COALESCE(t.enfant_id, t.parent_id) AS socialissue_id
|
||||
FROM (
|
||||
SELECT p.period_id,
|
||||
(SELECT id FROM chill_person_social_issue WHERE title::jsonb->>'fr' = icp.parent1::jsonb->>'fr' AND parent_id IS NULL) AS parent_id, icp.parent1,
|
||||
(SELECT id FROM chill_person_social_issue WHERE title::jsonb->>'fr' = icp.enfant1::jsonb->>'fr' AND parent_id =
|
||||
(SELECT id FROM chill_person_social_issue WHERE title::jsonb->>'fr' = icp.parent1::jsonb->>'fr' AND parent_id IS NULL)) AS enfant_id, icp.enfant1
|
||||
FROM import.periodes p
|
||||
JOIN import.choix_periodes icp ON p.acp_socialissues = icp.acp_socialissues
|
||||
ORDER BY id) AS t;
|
||||
JOIN import.choix_periodes icp ON p.acp_socialissues = icp.acp_social_issues
|
||||
ORDER BY id) AS t
|
||||
WHERE COALESCE(t.enfant_id, t.parent_id) IS NOT NULL;
|
||||
|
||||
-- 57. Link referrer to periods
|
||||
UPDATE chill_person_accompanying_period acp
|
||||
SET user_id = COALESCE(
|
||||
(SELECT id FROM users WHERE users.username = ip.referrer),
|
||||
1 -- default value ?
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)
|
||||
)
|
||||
FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
--SELECT ip.id, (SELECT id FROM users WHERE users.username = ip.referrer) AS referrer_id, ip.referrer, acp.id as period_id, acp.user_id FROM chill_person_accompanying_period acp JOIN import.periodes ip ON ip.period_id = acp.id ORDER BY ip.id;
|
||||
|
||||
-- 57bis. Link work social actions to periods
|
||||
INSERT INTO chill_person_accompanying_period_work (
|
||||
id,
|
||||
note,
|
||||
createdat,
|
||||
startdate,
|
||||
enddate,
|
||||
createdautomatically,
|
||||
createdautomaticallyreason,
|
||||
accompanyingperiod_id,
|
||||
socialaction_id,
|
||||
createdby_id,
|
||||
handlingthierparty_id,
|
||||
updatedat,
|
||||
updatedby_id,
|
||||
privatecomment_comments,
|
||||
version
|
||||
)
|
||||
SELECT
|
||||
nextval('chill_person_accompanying_period_work_id_seq'),
|
||||
'',
|
||||
CURRENT_TIMESTAMP,
|
||||
COALESCE(ip.openingdate1, date(date_trunc('year', CURRENT_DATE))),
|
||||
ip.closingdate1,
|
||||
true,
|
||||
'Imported from canvas',
|
||||
ip.period_id,
|
||||
sa.id,
|
||||
COALESCE(acp.user_id, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)),
|
||||
null,
|
||||
CURRENT_TIMESTAMP,
|
||||
COALESCE(acp.user_id, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)),
|
||||
'{}'::json,
|
||||
1
|
||||
FROM import.periodes ip
|
||||
JOIN chill_person_accompanying_period acp ON acp.id = ip.period_id
|
||||
JOIN LATERAL (
|
||||
SELECT MIN(id) AS id
|
||||
FROM chill_person_social_action s
|
||||
WHERE s.title::jsonb->>'fr' = trim(ip.work_socialaction)
|
||||
) sa ON sa.id IS NOT NULL
|
||||
WHERE trim(COALESCE(ip.work_socialaction, '')) != ''
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM chill_person_accompanying_period_work w
|
||||
WHERE w.accompanyingperiod_id = ip.period_id
|
||||
AND w.socialaction_id = sa.id
|
||||
);
|
||||
SELECT setval('chill_person_accompanying_period_work_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_work));
|
||||
|
||||
-- 58. Link scopes to periods
|
||||
INSERT INTO accompanying_periods_scopes (accompanying_period_id, scope_id)
|
||||
SELECT ip.period_id, COALESCE(
|
||||
(SELECT id FROM scopes s WHERE ip.acp_scopes1::jsonb->>'fr' = s.name::jsonb->>'fr'),
|
||||
(SELECT id from scopes s WHERE s.name::jsonb->>'fr' = 'tous') -- default value 'tous'
|
||||
)
|
||||
FROM import.periodes ip;
|
||||
SELECT t.period_id, t.scope_id
|
||||
FROM (
|
||||
SELECT ip.period_id, COALESCE(
|
||||
(SELECT id FROM scopes s WHERE ip.acp_scopes1::jsonb->>'fr' = s.name::jsonb->>'fr'),
|
||||
(SELECT id from scopes s WHERE s.name::jsonb->>'fr' = 'Principal'),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM scopes)
|
||||
) AS scope_id
|
||||
FROM import.periodes ip
|
||||
) AS t
|
||||
WHERE t.scope_id IS NOT NULL;
|
||||
|
||||
-- 59. Link origin to periods
|
||||
UPDATE chill_person_accompanying_period acp SET origin_id =
|
||||
@@ -460,6 +629,318 @@ FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
|
||||
-- ~~Link closingmotive~~ (to be removed from csv)
|
||||
|
||||
-- 64. Complete table chill_main_location_type
|
||||
ALTER TABLE import.choix_localisations ADD COLUMN title1 JSONB;
|
||||
UPDATE import.choix_localisations SET title1=json_build_object('fr', trim(title)) WHERE title!='';
|
||||
INSERT INTO chill_main_location_type (id, title, availableforusers, addressrequired, contactdata, active, defaultfor, editablebyusers)
|
||||
SELECT nextval('chill_main_location_type_id_seq'),
|
||||
t.title1, true, coalesce(t."addressRequired", 'optional'), coalesce(t."contactData", 'optional'), true,
|
||||
t."defaultFor", coalesce(t."editableByUsers", true)
|
||||
FROM import.choix_localisations AS t WHERE title!='' AND
|
||||
NOT EXISTS ( SELECT 1 FROM chill_main_location_type WHERE title::jsonb->>'fr' = t.title1::jsonb->>'fr' );
|
||||
|
||||
-- 65. Add addresses to be linked with location
|
||||
-- a) add new columns
|
||||
ALTER TABLE import.localisations ADD column postcode_arr BIGINT[];
|
||||
ALTER TABLE import.localisations ADD column address_id BIGINT;
|
||||
ALTER TABLE import.localisations ADD column address_ref_id BIGINT;
|
||||
|
||||
-- b) find and add postal code references. Check missing correspondances (if you can)
|
||||
UPDATE import.localisations
|
||||
SET postcode_arr = (
|
||||
SELECT array_agg(pc.id)
|
||||
FROM chill_main_postal_code AS pc
|
||||
WHERE pc.code = import.localisations.postcode
|
||||
AND pc.origin = 0
|
||||
);
|
||||
|
||||
-- c) find and add reference addresses. Check missing correspondances (if you can)
|
||||
UPDATE import.localisations AS loc SET address_ref_id = cmar.id FROM chill_main_address_reference AS cmar
|
||||
WHERE
|
||||
cmar.postcode_id = ANY(loc.postcode_arr)
|
||||
AND similarity(trim(loc.street), trim(cmar.street)) > 0.6
|
||||
AND trim(loc.streetnumber) = trim(cmar.streetnumber);
|
||||
|
||||
--SELECT * FROM import.localisations as l
|
||||
--WHERE l.address_ref_id IS NULL
|
||||
|
||||
-- d) fill new chill address
|
||||
UPDATE import.localisations SET address_id = nextval('chill_main_address_id_seq');
|
||||
|
||||
-- e) insert reference address into chill_main_addresses
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom, addressreference_id, refstatus, point, createdat, updatedat, createdby_id, updatedby_id)
|
||||
SELECT address_id, postcode_arr[1], street, coalesce(streetnumber, ''), coalesce(extra,''), CURRENT_DATE, address_ref_id, 'match',
|
||||
(SELECT point FROM chill_main_address_reference WHERE id = address_ref_id),
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)
|
||||
FROM import.localisations WHERE address_ref_id IS NOT NULL;
|
||||
|
||||
-- f) insert new addresses in chill_main_addresses
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom, createdat, updatedat, createdby_id, updatedby_id)
|
||||
SELECT address_id, postcode_arr[1], street, coalesce(streetnumber, ''), coalesce(extra,''), CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)
|
||||
FROM import.localisations WHERE address_ref_id IS NULL;
|
||||
SELECT setval('chill_main_address_id_seq', (SELECT COALESCE(max(id)) FROM chill_main_address));
|
||||
|
||||
-- 66. Import locations
|
||||
DO $$
|
||||
DECLARE
|
||||
intl text := 33; -- change this value to +32 or +33, or...
|
||||
BEGIN
|
||||
UPDATE import.localisations SET phonenumber=NULLIF(regexp_replace(phonenumber, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||
UPDATE import.localisations SET phonenumber = CASE -- remove intl prefix
|
||||
WHEN LEFT(phonenumber, 2) = '00' THEN substr(phonenumber, 5, length(phonenumber) - 4)
|
||||
WHEN LEFT(phonenumber, 2) = '33' THEN substr(phonenumber, 3, length(phonenumber) - 2)
|
||||
ELSE regexp_replace(phonenumber, '^0', '') -- remove first 0 prefix
|
||||
END;
|
||||
UPDATE import.localisations SET phonenumber=regexp_replace(phonenumber, '(.*)', '+' || intl || '\1'); -- add intl prefix
|
||||
|
||||
UPDATE import.localisations SET phonenumber1=NULLIF(regexp_replace(phonenumber1, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||
UPDATE import.localisations SET phonenumber1 = CASE -- remove intl prefix
|
||||
WHEN LEFT(phonenumber1, 2) = '00' THEN substr(phonenumber1, 5, length(phonenumber1) - 4)
|
||||
WHEN LEFT(phonenumber1, 2) = '33' THEN substr(phonenumber1, 3, length(phonenumber1) - 2)
|
||||
ELSE regexp_replace(phonenumber1, '^0', '') -- remove first 0 prefix
|
||||
END;
|
||||
UPDATE import.localisations SET phonenumber1=regexp_replace(phonenumber1, '(.*)', '+' || intl || '\1'); -- add intl prefix
|
||||
END $$;
|
||||
|
||||
INSERT INTO public.chill_main_location
|
||||
(id, address_id, "name", phonenumber1, phonenumber2, email, availableforusers, createdat, updatedat, locationtype_id, createdby_id, updatedby_id, active)
|
||||
SELECT nextval('chill_main_location_id_seq'),
|
||||
t.address_id,
|
||||
trim(t.locname),
|
||||
t.phonenumber,
|
||||
t.phonenumber1,
|
||||
t.email,
|
||||
TRUE,
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT id FROM public.chill_main_location_type AS mlt WHERE mlt.title::jsonb->>'fr' = trim(t.loctype)),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
TRUE
|
||||
FROM import.localisations AS t WHERE locname != '' AND
|
||||
NOT EXISTS ( SELECT 1 FROM chill_main_location WHERE "name" = trim(t.locname) );
|
||||
|
||||
|
||||
-- 67. Import/update user job (métiers)
|
||||
INSERT INTO public.chill_main_user_job
|
||||
(id, "label", active)
|
||||
SELECT
|
||||
nextval('chill_main_user_job_id_seq'),
|
||||
json_build_object('fr', trim(t.metier)),
|
||||
TRUE
|
||||
FROM (
|
||||
SELECT DISTINCT metier
|
||||
FROM import.users
|
||||
) AS t
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM chill_main_user_job WHERE label::jsonb->>'fr' = t.metier );
|
||||
|
||||
-- 68. Imports users
|
||||
DO $$
|
||||
DECLARE
|
||||
intl text := 33; -- change this value to +32 or +33, or...
|
||||
BEGIN
|
||||
UPDATE import.users SET phonenumber=NULLIF(regexp_replace(phonenumber, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||
UPDATE import.users SET phonenumber = CASE -- remove intl prefix
|
||||
WHEN LEFT(phonenumber, 2) = '00' THEN substr(phonenumber, 5, length(phonenumber) - 4)
|
||||
WHEN LEFT(phonenumber, 2) = '33' THEN substr(phonenumber, 3, length(phonenumber) - 2)
|
||||
ELSE regexp_replace(phonenumber, '^0', '') -- remove first 0 prefix
|
||||
END;
|
||||
UPDATE import.users SET phonenumber=regexp_replace(phonenumber, '(.*)', '+' || intl || '\1'); -- add intl prefix
|
||||
|
||||
END $$;
|
||||
|
||||
INSERT INTO public.users
|
||||
(id, username, "password", enabled, "locked", usernamecanonical, email, emailcanonical, "label", civility_id, phonenumber)
|
||||
SELECT nextval('users_id_seq'),
|
||||
SPLIT_PART(t."email",'@',1),
|
||||
'',
|
||||
TRUE,
|
||||
TRUE,
|
||||
t."login",
|
||||
t.email,
|
||||
t.email,
|
||||
CONCAT(t.prenom, ' ', t.nom),
|
||||
CASE
|
||||
WHEN t.civility = 'F' THEN (SELECT id FROM chill_main_civility WHERE "name"::jsonb->>'fr' = 'Madame')
|
||||
WHEN t.civility = 'M' THEN (SELECT id FROM chill_main_civility WHERE "name"::jsonb->>'fr' = 'Monsieur')
|
||||
ELSE NULL
|
||||
END,
|
||||
t.phonenumber
|
||||
FROM import.users AS t
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM users WHERE username = SPLIT_PART(t."email",'@',1) );
|
||||
|
||||
-- Update also user job history
|
||||
INSERT INTO public.chill_main_user_job_history
|
||||
(id, job_id, user_id, enddate, startdate)
|
||||
SELECT
|
||||
nextval('chill_main_user_job_history_id_seq'),
|
||||
(SELECT id FROM chill_main_user_job WHERE label::jsonb->>'fr' = t.metier),
|
||||
(SELECT id FROM users WHERE username = SPLIT_PART(t."email",'@',1)),
|
||||
NULL::timestamp without time zone,
|
||||
CURRENT_DATE
|
||||
FROM import.users AS t
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM chill_main_user_job_history WHERE user_id = (SELECT id FROM users WHERE username = SPLIT_PART(t."email",'@',1)) );
|
||||
|
||||
|
||||
-- 69. Complete table party_category
|
||||
WITH categories AS (SELECT DISTINCT(trim(t.categorie)) AS title
|
||||
FROM IMPORT.tiers AS t)
|
||||
INSERT INTO chill_3party.party_category (id, "name", active)
|
||||
SELECT
|
||||
nextval('chill_3party.party_category_id_seq'),
|
||||
jsonb_build_object('fr', c.title),
|
||||
TRUE
|
||||
FROM categories AS c
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM chill_3party.party_category WHERE "name"::json->>'fr' = c.title );
|
||||
|
||||
-- 70. Add addresses to be linked with third parties
|
||||
-- a) add new columns
|
||||
ALTER TABLE import.tiers ADD column postcode_arr BIGINT[];
|
||||
ALTER TABLE import.tiers ADD column address_id BIGINT;
|
||||
ALTER TABLE import.tiers ADD column address_ref_id BIGINT;
|
||||
|
||||
-- b) find and add postal code references. Check missing correspondances (if you can)
|
||||
UPDATE import.tiers
|
||||
SET postcode_arr = (
|
||||
SELECT array_agg(pc.id)
|
||||
FROM chill_main_postal_code AS pc
|
||||
WHERE pc.code = import.tiers.cp
|
||||
AND pc.origin = 0
|
||||
);
|
||||
|
||||
-- c) find and add reference addresses. Check missing correspondances (if you can)
|
||||
UPDATE import.tiers AS tiers SET address_ref_id = cmar.id FROM chill_main_address_reference AS cmar
|
||||
WHERE
|
||||
cmar.postcode_id = ANY(tiers.postcode_arr)
|
||||
AND similarity(trim(tiers.adresse), trim(cmar.street)) > 0.6;
|
||||
|
||||
--SELECT * FROM import.tiers as l
|
||||
--WHERE l.address_ref_id IS NULL
|
||||
|
||||
-- d) fill new chill address
|
||||
UPDATE import.tiers SET address_id = nextval('chill_main_address_id_seq') WHERE postcode_arr IS NOT NULL;
|
||||
|
||||
-- e) insert reference address into chill_main_addresses
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom, addressreference_id, refstatus, point, createdat, updatedat, createdby_id, updatedby_id)
|
||||
SELECT address_id, postcode_arr[1], coalesce(adresse,''), '', '', CURRENT_DATE, address_ref_id, 'match',
|
||||
(SELECT point FROM chill_main_address_reference WHERE id = address_ref_id),
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)
|
||||
FROM import.tiers WHERE address_ref_id IS NOT NULL;
|
||||
|
||||
-- f) insert new addresses in chill_main_addresses
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom, createdat, updatedat, createdby_id, updatedby_id)
|
||||
SELECT address_id, postcode_arr[1], coalesce(adresse,''), '', '', CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users)
|
||||
FROM import.tiers WHERE address_ref_id IS NULL AND postcode_arr IS NOT NULL;
|
||||
SELECT setval('chill_main_address_id_seq', (SELECT COALESCE(max(id)) FROM chill_main_address));
|
||||
|
||||
-- 71. Import third parties
|
||||
DO $$
|
||||
DECLARE
|
||||
intl text := 33; -- change this value to +32 or +33, or...
|
||||
BEGIN
|
||||
UPDATE import.tiers SET phonenumber=NULLIF(regexp_replace(phonenumber, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||
UPDATE import.tiers SET phonenumber = CASE -- remove intl prefix
|
||||
WHEN LEFT(phonenumber, 2) = '00' THEN substr(phonenumber, 5, length(phonenumber) - 4)
|
||||
WHEN LEFT(phonenumber, 2) = '33' THEN substr(phonenumber, 3, length(phonenumber) - 2)
|
||||
ELSE regexp_replace(phonenumber, '^0', '') -- remove first 0 prefix
|
||||
END;
|
||||
UPDATE import.tiers SET phonenumber=regexp_replace(phonenumber, '(.*)', '+' || intl || '\1'); -- add intl prefix
|
||||
|
||||
UPDATE import.tiers SET phonenumber_2=NULLIF(regexp_replace(phonenumber_2, '[^0-9]', '', 'g'), ''); -- remove all NaN chars
|
||||
UPDATE import.tiers SET phonenumber_2 = CASE -- remove intl prefix
|
||||
WHEN LEFT(phonenumber_2, 2) = '00' THEN substr(phonenumber_2, 5, length(phonenumber_2) - 4)
|
||||
WHEN LEFT(phonenumber_2, 2) = '33' THEN substr(phonenumber_2, 3, length(phonenumber_2) - 2)
|
||||
ELSE regexp_replace(phonenumber_2, '^0', '') -- remove first 0 prefix
|
||||
END;
|
||||
UPDATE import.tiers SET phonenumber_2=regexp_replace(phonenumber_2, '(.*)', '+' || intl || '\1'); -- add intl prefix
|
||||
END $$;
|
||||
|
||||
|
||||
-- Insert companies (parent) first
|
||||
INSERT INTO chill_3party.third_party
|
||||
(id, "name", telephone, email, "comment", "types", active, address_id, parent_id, updated_by, name_company, acronym, created_at, updated_at, created_by, civility_id, kind, canonicalized, contact_data_anonymous, firstname, profession, telephone2)
|
||||
SELECT nextval('chill_3party.third_party_id_seq'),
|
||||
trim(nom),
|
||||
t.phonenumber,
|
||||
t.email,
|
||||
concat('horaires: ', t.horaires, ' \n \n observations: ', t.observations),
|
||||
NULL,
|
||||
TRUE,
|
||||
t.address_id,
|
||||
NULL, -- parent
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
NULL, -- service/dpt
|
||||
t.acronym,
|
||||
CURRENT_DATE,
|
||||
CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users),
|
||||
NULL,
|
||||
'company', -- il n'y a pas de personnes physiques ('contact)
|
||||
lower(trim(nom)),
|
||||
FALSE,
|
||||
'',
|
||||
'',
|
||||
t.phonenumber_2
|
||||
FROM import.tiers AS t WHERE t.nom != ''
|
||||
AND t.personne_nom IS NULL
|
||||
AND NOT EXISTS ( SELECT 1 FROM chill_3party.third_party WHERE "name" = trim(t.nom) );
|
||||
|
||||
-- Do the mapping of thirdparty categories
|
||||
INSERT INTO chill_3party.thirdparty_category
|
||||
(thirdparty_id, category_id)
|
||||
SELECT DISTINCT
|
||||
tp.id,
|
||||
(SELECT id FROM chill_3party.party_category WHERE "name"::jsonb->>'fr' = t.categorie)
|
||||
FROM import.tiers AS t LEFT JOIN chill_3party.third_party AS tp ON trim(t.nom) = tp."name"
|
||||
WHERE tp.id IS NOT NULL;
|
||||
|
||||
-- Insert contact (child) second
|
||||
INSERT INTO chill_3party.third_party
|
||||
(id, "name", telephone, email, "comment", "types", active, address_id, parent_id, updated_by, name_company, acronym, created_at, updated_at, created_by, civility_id, kind, canonicalized, contact_data_anonymous, firstname, profession, telephone2)
|
||||
SELECT
|
||||
nextval('chill_3party.third_party_id_seq'),
|
||||
trim(t.personne_nom),
|
||||
NULL, -- telephone
|
||||
NULL::character varying, -- email
|
||||
'', -- comment
|
||||
NULL, -- types
|
||||
TRUE, -- active
|
||||
NULL, -- address_id
|
||||
(SELECT id FROM chill_3party.third_party AS tp WHERE tp."name" = trim(t.nom) LIMIT 1), -- parent_id
|
||||
(SELECT id FROM users ORDER BY id LIMIT 1), -- updated_by
|
||||
NULL::character varying, -- name_company
|
||||
NULL::character varying, -- acronym
|
||||
CURRENT_DATE, -- created_at
|
||||
CURRENT_DATE, -- updated_at
|
||||
(SELECT id FROM users ORDER BY id LIMIT 1), -- created_by
|
||||
CASE
|
||||
WHEN t.personne_civilite = 'Mme' THEN (SELECT id FROM chill_main_civility WHERE "name"::jsonb->>'fr' = 'Madame')
|
||||
WHEN t.personne_civilite = 'M' THEN (SELECT id FROM chill_main_civility WHERE "name"::jsonb->>'fr' = 'Monsieur')
|
||||
ELSE NULL
|
||||
END, -- civility_id
|
||||
'contact', -- kind
|
||||
lower(trim(t.personne_nom)),
|
||||
FALSE, -- contact_data_anonymous
|
||||
COALESCE(trim(t.personne_prenom),''), -- firstname
|
||||
''::text, -- profession
|
||||
NULL::character varying -- telephone2
|
||||
FROM import.tiers AS t WHERE t.nom != ''
|
||||
AND t.personne_nom IS NOT NULL AND lower(trim(t.personne_nom)) IS NOT NULL
|
||||
AND NOT EXISTS ( SELECT 1 FROM chill_3party.third_party WHERE "name" = trim(t.personne_nom) );
|
||||
|
||||
-- ========================================================================================= --
|
||||
|
||||
@@ -467,6 +948,25 @@ FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
-- DOWN
|
||||
--
|
||||
|
||||
\if :run_down
|
||||
|
||||
-- Undo 68.
|
||||
--TODO
|
||||
|
||||
-- Undo 67.
|
||||
--TODO/NOT CRITICAL
|
||||
|
||||
-- Undo 66.
|
||||
DELETE FROM chill_main_location WHERE createdat >= CURRENT_DATE;
|
||||
|
||||
|
||||
-- Undo 65.
|
||||
DELETE FROM chill_main_address WHERE createdat >= CURRENT_DATE;
|
||||
|
||||
|
||||
-- Undo 64.
|
||||
--TODO/NOT CRITICAL
|
||||
|
||||
-- Undo 63.
|
||||
UPDATE chill_person_accompanying_period acp SET pinnedcomment_id = null FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
UPDATE import.periodes SET comment1_content = '' WHERE comment1_content IS NULL;
|
||||
@@ -493,6 +993,10 @@ DELETE FROM accompanying_periods_scopes acs USING import.periodes ip WHERE acs.a
|
||||
-- Undo 57.
|
||||
UPDATE chill_person_accompanying_period acp SET user_id = null FROM import.periodes ip WHERE ip.period_id = acp.id;
|
||||
|
||||
-- Undo 57bis.
|
||||
DELETE FROM chill_person_accompanying_period_work w USING import.periodes ip WHERE w.accompanyingperiod_id = ip.period_id;
|
||||
SELECT setval('chill_person_accompanying_period_work_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_work));
|
||||
|
||||
-- Undo 56.
|
||||
DELETE FROM chill_person_accompanying_period_social_issues asi USING import.periodes ip WHERE asi.accompanyingperiod_id = ip.period_id;
|
||||
|
||||
@@ -535,7 +1039,7 @@ SELECT setval('chill_person_household_id_seq', (SELECT COALESCE(max(id),1) FROM
|
||||
-- Undo 43.
|
||||
DELETE FROM chill_main_address addr USING import.personnes ip WHERE addr.id = ip.address_id;
|
||||
SELECT setval('chill_main_address_id_seq', (SELECT COALESCE(max(id),1) FROM chill_main_address));
|
||||
ALTER TABLE import.personnes DROP column postcode_id;
|
||||
ALTER TABLE import.personnes DROP column postcode_arr;
|
||||
ALTER TABLE import.personnes DROP column address_id;
|
||||
|
||||
-- Undo 42.
|
||||
@@ -595,6 +1099,23 @@ ALTER TABLE import.personnes DROP COLUMN gender1;
|
||||
ALTER TABLE import.personnes DROP COLUMN civility1;
|
||||
|
||||
-- Undo 14.
|
||||
DELETE FROM chill_person_social_action sa
|
||||
USING import.choix_periodes icp
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT si.id
|
||||
FROM chill_person_social_issue si
|
||||
WHERE si.title::jsonb->>'fr' = icp.work_social_issue1::jsonb->>'fr'
|
||||
ORDER BY (si.parent_id IS NULL), si.id
|
||||
LIMIT 1
|
||||
) issue ON true
|
||||
WHERE sa.title::jsonb->>'fr' = icp.work_social_action1::jsonb->>'fr'
|
||||
AND (
|
||||
(sa.issue_id IS NULL AND issue.id IS NULL)
|
||||
OR sa.issue_id = issue.id
|
||||
);
|
||||
SELECT setval('chill_person_social_action_id_seq', (SELECT COALESCE(max(id),1) FROM chill_person_social_action));
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN work_social_issue1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN work_social_action1;
|
||||
|
||||
-- Undo 13.
|
||||
DELETE FROM chill_person_social_issue USING import.choix_periodes i
|
||||
@@ -671,6 +1192,7 @@ ALTER TABLE import.periodes DROP COLUMN closingdate1;
|
||||
|
||||
|
||||
-- =============
|
||||
\endif
|
||||
-- QUESTIONS
|
||||
--
|
||||
-- définir par défaut: quel user, quel centre ?
|
||||
|
||||
142
sql/prepare-import.sql
Executable file
142
sql/prepare-import.sql
Executable file
@@ -0,0 +1,142 @@
|
||||
CREATE SCHEMA "import";
|
||||
|
||||
CREATE TABLE "import".choix_personnes (
|
||||
civility varchar(50) NULL,
|
||||
gender varchar(50) NULL,
|
||||
maritalstatus varchar(50) NULL,
|
||||
country varchar(50) NULL,
|
||||
household_composition_type varchar(50) NULL,
|
||||
household_position varchar(50) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "import".personnes (
|
||||
id varchar(50) NULL,
|
||||
civility varchar(50) NULL,
|
||||
lastname varchar(50) NULL,
|
||||
firstname varchar(50) NULL,
|
||||
gender varchar(50) NULL,
|
||||
gendercomment varchar(50) NULL,
|
||||
nationality varchar(50) NULL,
|
||||
memo varchar(50) NULL,
|
||||
birthdate varchar(50) NULL,
|
||||
place_of_birth varchar(50) NULL,
|
||||
countryofbirth varchar(50) NULL,
|
||||
deathdate varchar(50) NULL,
|
||||
email varchar(50) NULL,
|
||||
phonenumber varchar(50) NULL,
|
||||
mobilenumber varchar(50) NULL,
|
||||
contactinfo varchar(50) NULL,
|
||||
street varchar(50) NULL,
|
||||
extra varchar(50) NULL,
|
||||
streetnumber varchar(50) NULL,
|
||||
postcode varchar(50) NULL,
|
||||
country varchar(50) NULL,
|
||||
validfrom varchar(50) NULL,
|
||||
maritalstatus varchar(50) NULL,
|
||||
maritalstatuscomment varchar(50) NULL,
|
||||
numberofchildren integer NULL,
|
||||
household_composition_type varchar(50) NULL,
|
||||
household_position varchar(50) NULL,
|
||||
household_startdate varchar(50) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "import".choix_periodes (
|
||||
closingmotive varchar(50) NULL,
|
||||
origin varchar(50) NULL,
|
||||
acp_scopes varchar(50) NULL,
|
||||
job varchar(50) NULL,
|
||||
referrer varchar(50) NULL,
|
||||
parent varchar(50) NULL,
|
||||
enfant varchar(50) NULL,
|
||||
acp_social_issues varchar(50) NULL,
|
||||
work_social_action varchar(50) NULL,
|
||||
street varchar(128) NULL,
|
||||
extra varchar(50) NULL,
|
||||
streetnumber integer NULL,
|
||||
postcode integer NULL,
|
||||
country varchar(50) NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE "import".periodes (
|
||||
id varchar(50) NULL,
|
||||
nom varchar(50) NULL,
|
||||
openingdate varchar(50) NULL,
|
||||
closingdate varchar(50) NULL,
|
||||
closingmotive varchar(50) NULL,
|
||||
origin varchar(50) NULL,
|
||||
remark integer NULL,
|
||||
intensity varchar(50) NULL,
|
||||
referrer varchar(50) NULL,
|
||||
job varchar(50) NULL,
|
||||
acp_scopes varchar(50) NULL,
|
||||
"address" varchar(50) NULL,
|
||||
personlocation varchar(50) NULL,
|
||||
addresslocation varchar(50) NULL,
|
||||
acp_socialissues varchar(50) NULL,
|
||||
work_socialaction varchar(50) NULL,
|
||||
comment1_content varchar(50) NULL,
|
||||
comment2_content varchar(50) NULL,
|
||||
comment3_content varchar(50) NULL,
|
||||
comment4_content varchar(50) NULL,
|
||||
comment5_content varchar(50) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "import".choix_localisations (
|
||||
title varchar(50) NULL,
|
||||
"addressRequired" varchar(32) NULL,
|
||||
"availableForUsers" boolean DEFAULT TRUE,
|
||||
"contactData" varchar(32) NULL,
|
||||
"defaultFor" varchar(32) NULL,
|
||||
"editableByUsers" boolean DEFAULT TRUE
|
||||
);
|
||||
|
||||
CREATE TABLE "import".localisations (
|
||||
id varchar(50) NULL,
|
||||
locname varchar(50) NULL,
|
||||
phonenumber varchar(50) NULL,
|
||||
phonenumber1 varchar(50) NULL,
|
||||
email varchar(50) NULL,
|
||||
loctype varchar(50) NULL,
|
||||
street varchar(50) NULL,
|
||||
extra varchar(50) NULL,
|
||||
streetnumber varchar(50) NULL,
|
||||
postcode varchar(50) NULL,
|
||||
country varchar(50) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "import".users (
|
||||
id varchar(50) NULL,
|
||||
"login" varchar(50) NULL,
|
||||
civility varchar(50) NULL,
|
||||
nom varchar(50) NULL,
|
||||
prenom varchar(50) NULL,
|
||||
libl varchar(50) NULL,
|
||||
nom_prenom varchar(50) NULL,
|
||||
phonenumber varchar(50) NULL,
|
||||
email varchar(50) NULL,
|
||||
metier varchar(50) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE "import".tiers (
|
||||
id varchar(50) NULL,
|
||||
categorie VARCHAR(255),
|
||||
secteur_as VARCHAR(255),
|
||||
commune VARCHAR(255),
|
||||
nom VARCHAR(255),
|
||||
acronym VARCHAR(64),
|
||||
phonenumber VARCHAR(20),
|
||||
phonenumber_2 VARCHAR(20),
|
||||
email VARCHAR(255),
|
||||
personne_nom VARCHAR(255),
|
||||
personne_prenom VARCHAR(255),
|
||||
personne_civilite VARCHAR(20),
|
||||
adresse TEXT,
|
||||
cp VARCHAR(10),
|
||||
tiers_parent VARCHAR(255),
|
||||
tiers_physique_vs_morale VARCHAR(50),
|
||||
point_de_contact_sur_le_territoire TEXT,
|
||||
coordonnees TEXT,
|
||||
horaires TEXT,
|
||||
observations TEXT
|
||||
);
|
||||
417
sql/remove-import-data.sql
Normal file
417
sql/remove-import-data.sql
Normal file
@@ -0,0 +1,417 @@
|
||||
BEGIN;
|
||||
|
||||
-- Nettoyage des donnees importees a partir des tables du schema import.
|
||||
-- Ce script suppose que sql/import.sql a ete execute au moins partiellement.
|
||||
|
||||
-- 1. Commentaires et liaisons des periodes
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'periodes' AND column_name = 'period_id'
|
||||
) THEN
|
||||
UPDATE chill_person_accompanying_period acp
|
||||
SET pinnedcomment_id = NULL
|
||||
FROM import.periodes ip
|
||||
WHERE acp.id = ip.period_id;
|
||||
|
||||
DELETE FROM chill_person_accompanying_period_comment com
|
||||
USING import.periodes ip
|
||||
WHERE com.accompanyingperiod_id = ip.period_id;
|
||||
|
||||
DELETE FROM chill_person_accompanying_period_work work
|
||||
USING import.periodes ip
|
||||
WHERE work.accompanyingperiod_id = ip.period_id;
|
||||
|
||||
DELETE FROM chill_person_accompanying_period_social_issues asi
|
||||
USING import.periodes ip
|
||||
WHERE asi.accompanyingperiod_id = ip.period_id;
|
||||
|
||||
DELETE FROM chill_person_accompanying_period_location_history hist
|
||||
USING import.periodes ip
|
||||
WHERE hist.period_id = ip.period_id;
|
||||
|
||||
DELETE FROM accompanying_periods_scopes scopes_link
|
||||
USING import.periodes ip
|
||||
WHERE scopes_link.accompanying_period_id = ip.period_id;
|
||||
|
||||
DELETE FROM chill_person_accompanying_period_participation part
|
||||
USING import.periodes ip
|
||||
WHERE part.accompanyingperiod_id = ip.period_id;
|
||||
|
||||
UPDATE chill_person_accompanying_period acp
|
||||
SET addresslocation_id = NULL,
|
||||
personlocation_id = NULL,
|
||||
user_id = NULL,
|
||||
origin_id = NULL,
|
||||
job_id = NULL
|
||||
FROM import.periodes ip
|
||||
WHERE acp.id = ip.period_id;
|
||||
|
||||
DELETE FROM chill_person_accompanying_period acp
|
||||
USING import.periodes ip
|
||||
WHERE acp.id = ip.period_id;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 2. Menages, adresses et personnes
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'personnes' AND column_name = 'person_id'
|
||||
) THEN
|
||||
DELETE FROM chill_person_household_composition comp
|
||||
USING import.personnes ip
|
||||
WHERE comp.household_id = ip.person_id;
|
||||
|
||||
DELETE FROM chill_person_household_to_addresses hh_addr
|
||||
USING import.personnes ip
|
||||
WHERE hh_addr.household_id = ip.person_id;
|
||||
|
||||
DELETE FROM chill_person_household_members member
|
||||
USING import.personnes ip
|
||||
WHERE member.person_id = ip.person_id;
|
||||
|
||||
DELETE FROM chill_person_household hh
|
||||
USING import.personnes ip
|
||||
WHERE hh.id = ip.person_id;
|
||||
|
||||
DELETE FROM chill_person_person_center_history hist
|
||||
USING import.personnes ip
|
||||
WHERE hist.person_id = ip.person_id;
|
||||
|
||||
DELETE FROM chill_person_person person
|
||||
USING import.personnes ip
|
||||
WHERE person.id = ip.person_id;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'personnes' AND column_name = 'address_id'
|
||||
) THEN
|
||||
DELETE FROM chill_main_address addr
|
||||
USING import.personnes ip
|
||||
WHERE addr.id = ip.address_id;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 3. Adresses temporaires de periodes et localisations
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'address_location_id'
|
||||
) THEN
|
||||
DELETE FROM chill_main_address addr
|
||||
USING import.choix_periodes icp
|
||||
WHERE addr.id = icp.address_location_id;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'localisations' AND column_name = 'address_id'
|
||||
) THEN
|
||||
DELETE FROM chill_main_address addr
|
||||
USING import.localisations loc
|
||||
WHERE addr.id = loc.address_id;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 4. Localisations et types de localisation
|
||||
DELETE FROM chill_main_location loc
|
||||
USING import.localisations il
|
||||
WHERE loc.name = trim(il.locname);
|
||||
|
||||
DELETE FROM chill_main_location_type lt
|
||||
USING import.choix_localisations icl
|
||||
WHERE lt.title::jsonb->>'fr' = trim(icl.title)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM chill_main_location loc
|
||||
WHERE loc.locationtype_id = lt.id
|
||||
);
|
||||
|
||||
-- 5. Tiers et categories
|
||||
DELETE FROM chill_3party.thirdparty_category tpc
|
||||
USING chill_3party.third_party tp, import.tiers it
|
||||
WHERE tpc.thirdparty_id = tp.id
|
||||
AND (
|
||||
tp.name = trim(it.nom)
|
||||
OR tp.name = trim(it.personne_nom)
|
||||
);
|
||||
|
||||
DELETE FROM chill_3party.third_party tp
|
||||
USING import.tiers it
|
||||
WHERE tp.name = trim(it.personne_nom)
|
||||
OR tp.name = trim(it.nom);
|
||||
|
||||
DELETE FROM chill_3party.party_category pc
|
||||
USING import.tiers it
|
||||
WHERE pc.name::jsonb->>'fr' = trim(it.categorie)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM chill_3party.thirdparty_category tpc
|
||||
WHERE tpc.category_id = pc.id
|
||||
);
|
||||
|
||||
-- 6. Utilisateurs importes et historique des metiers
|
||||
DELETE FROM chill_main_user_job_history hist
|
||||
USING import.users iu
|
||||
WHERE hist.user_id = (
|
||||
SELECT id FROM users WHERE username = split_part(iu.email, '@', 1)
|
||||
);
|
||||
|
||||
DELETE FROM users u
|
||||
USING import.users iu
|
||||
WHERE u.username = split_part(iu.email, '@', 1);
|
||||
|
||||
DELETE FROM chill_main_user_job job
|
||||
USING import.users iu
|
||||
WHERE job.label::jsonb->>'fr' = trim(iu.metier)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM chill_main_user_job_history hist
|
||||
WHERE hist.job_id = job.id
|
||||
);
|
||||
|
||||
-- 7. Tables de reference ajoutees pendant l'import principal
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'work_social_action1'
|
||||
) AND EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'work_social_issue1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_social_action sa
|
||||
USING import.choix_periodes icp
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT si.id
|
||||
FROM chill_person_social_issue si
|
||||
WHERE si.title::jsonb->>'fr' = icp.work_social_issue1::jsonb->>'fr'
|
||||
ORDER BY (si.parent_id IS NULL), si.id
|
||||
LIMIT 1
|
||||
) issue ON true
|
||||
WHERE sa.title::jsonb->>'fr' = icp.work_social_action1::jsonb->>'fr'
|
||||
AND (
|
||||
(sa.issue_id IS NULL AND issue.id IS NULL)
|
||||
OR sa.issue_id = issue.id
|
||||
);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'enfant1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_social_issue child_issue
|
||||
USING import.choix_periodes icp
|
||||
WHERE child_issue.title::jsonb->>'fr' = icp.enfant1::jsonb->>'fr';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'parent1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_social_issue parent_issue
|
||||
USING import.choix_periodes icp
|
||||
WHERE parent_issue.title::jsonb->>'fr' = icp.parent1::jsonb->>'fr'
|
||||
AND parent_issue.parent_id IS NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DELETE FROM users u
|
||||
USING import.choix_periodes icp
|
||||
WHERE u.username::text = icp.referrer::text
|
||||
AND u.password = ''
|
||||
AND u.enabled = false;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'acp_scopes1'
|
||||
) THEN
|
||||
DELETE FROM scopes s
|
||||
USING import.choix_periodes icp
|
||||
WHERE s.name::jsonb->>'fr' = icp.acp_scopes1::jsonb->>'fr'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM accompanying_periods_scopes aps
|
||||
WHERE aps.scope_id = s.id
|
||||
);
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'job1'
|
||||
) THEN
|
||||
DELETE FROM chill_main_user_job job
|
||||
USING import.choix_periodes icp
|
||||
WHERE job.label::jsonb->>'fr' = icp.job1::jsonb->>'fr'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM chill_person_accompanying_period acp
|
||||
WHERE acp.job_id = job.id
|
||||
);
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'origin1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_accompanying_period_origin origin
|
||||
USING import.choix_periodes icp
|
||||
WHERE origin.label::jsonb->>'fr' = icp.origin1::jsonb->>'fr'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM chill_person_accompanying_period acp
|
||||
WHERE acp.origin_id = origin.id
|
||||
);
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_periodes' AND column_name = 'closingmotive1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_accompanying_period_closingmotive motive
|
||||
USING import.choix_periodes icp
|
||||
WHERE motive.name::jsonb->>'fr' = icp.closingmotive1::jsonb->>'fr';
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_personnes' AND column_name = 'household_position1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_household_position pos
|
||||
USING import.choix_personnes icp
|
||||
WHERE pos.label::jsonb->>'fr' = icp.household_position1::jsonb->>'fr';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_personnes' AND column_name = 'household_composition_type1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_household_composition_type comp_type
|
||||
USING import.choix_personnes icp
|
||||
WHERE comp_type.label::jsonb->>'fr' = icp.household_composition_type1::jsonb->>'fr';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_personnes' AND column_name = 'maritalstatus1'
|
||||
) THEN
|
||||
DELETE FROM chill_person_marital_status ms
|
||||
USING import.choix_personnes icp
|
||||
WHERE ms.name::jsonb->>'fr' = icp.maritalstatus1::jsonb->>'fr';
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_personnes' AND column_name = 'country1'
|
||||
) THEN
|
||||
DELETE FROM country c
|
||||
USING import.choix_personnes icp
|
||||
WHERE c.name::jsonb->>'fr' = icp.country1::jsonb->>'fr'
|
||||
AND c.id > 249;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'import' AND table_name = 'choix_personnes' AND column_name = 'civility1'
|
||||
) THEN
|
||||
DELETE FROM chill_main_civility civ
|
||||
USING import.choix_personnes icp
|
||||
WHERE civ.name::jsonb->>'fr' = icp.civility1::jsonb->>'fr';
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 8. Suppression des colonnes techniques ajoutees par sql/import.sql
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS person_id;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS address_id;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS address_ref_id;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS postcode_id;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS postcode_arr;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS postcode1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS birthdate1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS deathdate1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS validfrom1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS household_startdate1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS civility1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS gender1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS nationality1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS countryofbirth1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS maritalstatus1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS numberofchildren1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS placeofbirth1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS memo1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS household_composition_type1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS household_position1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS mobilenumber1;
|
||||
ALTER TABLE import.personnes DROP COLUMN IF EXISTS phonenumber1;
|
||||
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS period_id;
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS openingdate1;
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS closingdate1;
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS closingmotive1;
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS origin1;
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS job1;
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS acp_scopes1;
|
||||
ALTER TABLE import.periodes DROP COLUMN IF EXISTS intensity1;
|
||||
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS closingmotive1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS origin1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS job1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS acp_scopes1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS parent1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS enfant1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS work_social_action1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS work_social_issue1;
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN IF EXISTS address_location_id;
|
||||
|
||||
ALTER TABLE import.choix_personnes DROP COLUMN IF EXISTS civility1;
|
||||
ALTER TABLE import.choix_personnes DROP COLUMN IF EXISTS country1;
|
||||
ALTER TABLE import.choix_personnes DROP COLUMN IF EXISTS maritalstatus1;
|
||||
ALTER TABLE import.choix_personnes DROP COLUMN IF EXISTS household_composition_type1;
|
||||
ALTER TABLE import.choix_personnes DROP COLUMN IF EXISTS household_position1;
|
||||
|
||||
ALTER TABLE import.choix_localisations DROP COLUMN IF EXISTS title1;
|
||||
ALTER TABLE import.localisations DROP COLUMN IF EXISTS postcode_arr;
|
||||
ALTER TABLE import.localisations DROP COLUMN IF EXISTS address_id;
|
||||
ALTER TABLE import.localisations DROP COLUMN IF EXISTS address_ref_id;
|
||||
|
||||
ALTER TABLE import.tiers DROP COLUMN IF EXISTS postcode_arr;
|
||||
ALTER TABLE import.tiers DROP COLUMN IF EXISTS address_id;
|
||||
ALTER TABLE import.tiers DROP COLUMN IF EXISTS address_ref_id;
|
||||
|
||||
-- 9. Recalage des sequences principales
|
||||
SELECT setval('chill_person_accompanying_period_comment_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_comment));
|
||||
SELECT setval('chill_person_accompanying_period_work_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_work));
|
||||
SELECT setval('chill_person_accompanying_period_location_history_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_location_history));
|
||||
SELECT setval('chill_person_accompanying_period_participation_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_participation));
|
||||
SELECT setval('chill_person_accompanying_period_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period));
|
||||
SELECT setval('chill_person_household_composition_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_household_composition));
|
||||
SELECT setval('chill_person_household_members_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_household_members));
|
||||
SELECT setval('chill_person_household_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_household));
|
||||
SELECT setval('chill_person_person_center_history_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_person_center_history));
|
||||
SELECT setval('chill_person_person_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_person));
|
||||
SELECT setval('chill_person_social_action_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_social_action));
|
||||
SELECT setval('chill_person_social_issue_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_social_issue));
|
||||
SELECT setval('chill_person_accompanying_period_origin_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_origin));
|
||||
SELECT setval('chill_person_accompanying_period_closingmotive_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_accompanying_period_closingmotive));
|
||||
SELECT setval('chill_person_household_position_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_household_position));
|
||||
SELECT setval('chill_person_household_composition_type_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_person_household_composition_type));
|
||||
SELECT setval('chill_main_civility_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_main_civility));
|
||||
SELECT setval('country_id_seq', (SELECT COALESCE(max(id), 1) FROM country));
|
||||
SELECT setval('users_id_seq', (SELECT COALESCE(max(id), 1) FROM users));
|
||||
SELECT setval('scopes_id_seq', (SELECT COALESCE(max(id), 1) FROM scopes));
|
||||
SELECT setval('chill_main_user_job_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_main_user_job));
|
||||
SELECT setval('chill_main_address_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_main_address));
|
||||
SELECT setval('chill_main_location_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_main_location));
|
||||
SELECT setval('chill_main_location_type_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_main_location_type));
|
||||
SELECT setval('chill_main_user_job_history_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_main_user_job_history));
|
||||
SELECT setval('chill_3party.party_category_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_3party.party_category));
|
||||
SELECT setval('chill_3party.third_party_id_seq', (SELECT COALESCE(max(id), 1) FROM chill_3party.third_party));
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user