From 4e616980f63db935e7c98bd968f3ca2a6aac46af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Dubigny?= Date: Mon, 25 Nov 2024 11:41:58 +0100 Subject: [PATCH] feat: migrate anct email --- .../1732530843150_update-anct-email.cjs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 migrations/1732530843150_update-anct-email.cjs diff --git a/migrations/1732530843150_update-anct-email.cjs b/migrations/1732530843150_update-anct-email.cjs new file mode 100644 index 00000000..ff428b60 --- /dev/null +++ b/migrations/1732530843150_update-anct-email.cjs @@ -0,0 +1,20 @@ +exports.shorthands = undefined; + +exports.up = async (pgm) => { + await pgm.db.query(` + UPDATE users + SET + email = regexp_replace(email, '\\.prestataire@anct\\.gouv\\.fr$', '@ext.anct.gouv.fr'), + email_verified = FALSE + WHERE email LIKE '%.prestataire@anct.gouv.fr'; + `); +}; + +exports.down = async (pgm) => { + await pgm.db.query(` + UPDATE users + SET + email = regexp_replace(email, '@ext.anct.gouv.fr$', '.prestataire@anct.gouv.fr') + WHERE email LIKE '%@ext.anct.gouv.fr'; + `); +};