-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mise à jour du domaine Legipêche dans Monitorfish et dans le scraper (#…
- Loading branch information
Showing
7 changed files
with
95 additions
and
79 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
backend/src/main/resources/db/migration/internal/V0.237__Update_regulations_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
WITH id_regulations AS ( | ||
SELECT | ||
id, | ||
jsonb_array_elements(regulatory_references) regulatory_reference | ||
FROM regulations | ||
WHERE regulatory_references != 'null' | ||
), | ||
|
||
updated_id_regulations AS ( | ||
SELECT | ||
id, | ||
jsonb_set( | ||
regulatory_reference, | ||
'{url}', | ||
('"' || replace( | ||
replace( | ||
regulatory_reference->>'url', | ||
'http://legipeche.metier.i2', | ||
'http://legipeche.metier.e2.rie.gouv.fr' | ||
), | ||
'http://legipeche.metier.intranets.developpement-durable.ader.gouv.fr', | ||
'http://legipeche.metier.e2.rie.gouv.fr' | ||
) || '"')::jsonb | ||
) AS updated_regulatory_reference | ||
FROM id_regulations | ||
), | ||
|
||
updated_id_regulations_agg AS ( | ||
SELECT | ||
id, | ||
jsonb_agg(updated_regulatory_reference) AS updated_regulatory_references | ||
FROM updated_id_regulations | ||
GROUP BY id | ||
) | ||
|
||
UPDATE regulations r | ||
SET regulatory_references = u.updated_regulatory_references | ||
FROM updated_id_regulations_agg u | ||
WHERE r.id = u.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.