diff --git a/.talismanrc b/.talismanrc index 4fafdd7977..3a14a7c483 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,8 +1,8 @@ fileignoreconfig: - filename: _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql - checksum: cc7d142171d74e4ec6fac672fdf444f811db83367028dbe23a4d38196a01fa15 + checksum: fc2c3720259ae183a86581dc71daa2e2762964470d112ec8cc4bb7c83b44bc02 - filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql - checksum: 4961fa117ae2fd0b34744927341881ac645dd14b68c7b7ade799223080376bba + checksum: cc017bae84047b7761f61da63226cd3e419dc0bdd86264214922d4eeaf4cb5c1 - filename: packages/backend/src/_common/decorators/IsValidPasswordDecorator.ts checksum: f0d4b3cd2e6e2d9b1e0271c34d64adacf87a5f1e7a505402a20869962543608d - filename: packages/backend/src/_migrations/1699910877010-auto-migration.ts diff --git a/_scripts/db/dumps/domifa_test.postgres.custom.gz b/_scripts/db/dumps/domifa_test.postgres.custom.gz index 6cf045d740..478f988d7d 100644 Binary files a/_scripts/db/dumps/domifa_test.postgres.custom.gz and b/_scripts/db/dumps/domifa_test.postgres.custom.gz differ diff --git a/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql b/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql index f13c33404d..70c5af146a 100644 --- a/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql +++ b/_scripts/db/dumps/domifa_test.postgres.restore-data-only.sql @@ -129,7 +129,7 @@ COPY public.monitor_batch_process (uuid, "createdAt", "updatedAt", version, "pro -- Data for Name: open_data_places; Type: TABLE DATA; Schema: public; Owner: - -- -COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, "structureId") FROM stdin; +COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, "structureId", mail) FROM stdin; \. diff --git a/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql b/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql index d7665f68a8..0f3388aece 100644 --- a/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql +++ b/_scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql @@ -155,7 +155,7 @@ COPY public.monitor_batch_process (uuid, "createdAt", "updatedAt", version, "pro -- Data for Name: open_data_places; Type: TABLE DATA; Schema: public; Owner: - -- -COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, "structureId") FROM stdin; +COPY public.open_data_places (uuid, "createdAt", "updatedAt", version, nom, adresse, "complementAdresse", ville, "codePostal", departement, region, latitude, longitude, source, "uniqueId", software, "structureId", mail) FROM stdin; \. diff --git a/packages/backend/src/_migrations/1701726929874-auto-migration.ts b/packages/backend/src/_migrations/1701726929874-auto-migration.ts deleted file mode 100644 index aa916a8681..0000000000 --- a/packages/backend/src/_migrations/1701726929874-auto-migration.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import { domifaConfig } from "../config"; -import { appLogger } from "../util"; - -export class AutoMigration1701726929874 implements MigrationInterface { - name = "AutoMigration1701726929874"; - - public async up(queryRunner: QueryRunner): Promise { - appLogger.warn("[MIGRATION] Create procuration"); - if ( - domifaConfig().envId === "preprod" || - domifaConfig().envId === "prod" || - domifaConfig().envId === "local" - ) { - await queryRunner.query( - `ALTER TABLE "interactions" ADD "procuration" boolean` - ); - } - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "interactions" DROP COLUMN "procuration"` - ); - } -} diff --git a/packages/backend/src/_migrations/1701726996834-manual-migration.ts b/packages/backend/src/_migrations/1701726996834-manual-migration.ts deleted file mode 100644 index 595cd5b4d7..0000000000 --- a/packages/backend/src/_migrations/1701726996834-manual-migration.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import { appLogger } from "../util"; - -export class ManualMigration1701726996834 implements MigrationInterface { - public async up(queryRunner: QueryRunner): Promise { - appLogger.warn("[MIGRATION] Update procuration"); - - const count = await queryRunner.query( - `SELECT count(uuid) from interactions where LOWER(content) LIKE '%courrier remis au mandataire%'` - ); - - console.log(count); - await queryRunner.query( - `UPDATE interactions SET "procuration" = true WHERE LOWER(content) LIKE '%courrier remis au mandataire%';` - ); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async down(_queryRunner: QueryRunner): Promise { - // - } -} diff --git a/packages/backend/src/_migrations/1701788512483-manual-migration.ts b/packages/backend/src/_migrations/1701788512483-manual-migration.ts deleted file mode 100644 index d7cec28c9a..0000000000 --- a/packages/backend/src/_migrations/1701788512483-manual-migration.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import { interactionRepository, usagerRepository } from "../database"; -import { appLogger } from "../util"; - -export class ManualMigration1701788512483 implements MigrationInterface { - public async up(): Promise { - appLogger.info("[MIGRATION] Update 'napi' for 'VALIDE' usagers"); - const usagers = await usagerRepository - .createQueryBuilder("usager") - .select("uuid, options, decision") - .where( - `(options->'npai'->>'actif')::boolean = true and decision->>'statut' = 'VALIDE'` - ) - .getRawMany(); - - for (const usager of usagers) { - await usagerRepository.update( - { uuid: usager.uuid }, - { - options: { - ...usager.options, - npai: { - actif: false, - dateDebut: null, - }, - }, - } - ); - } - - appLogger.info("[MIGRATION] Delete npai from interactions "); - await interactionRepository.delete({ type: "npai" as any }); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - public async down(_queryRunner: QueryRunner): Promise { - // - } -} diff --git a/packages/backend/src/_migrations/1701870413794-auto-migration.ts b/packages/backend/src/_migrations/1701870413794-auto-migration.ts deleted file mode 100644 index 1c67c4b5c8..0000000000 --- a/packages/backend/src/_migrations/1701870413794-auto-migration.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; -import { domifaConfig } from "../config"; - -export class AutoMigration1701870413794 implements MigrationInterface { - name = "AutoMigration1701870413794"; - - public async up(queryRunner: QueryRunner): Promise { - if ( - domifaConfig().envId === "preprod" || - domifaConfig().envId === "prod" || - domifaConfig().envId === "local" - ) { - await queryRunner.query( - `ALTER TABLE "usager" ALTER COLUMN "lastInteraction" DROP DEFAULT` - ); - await queryRunner.query( - `ALTER TABLE "usager" ALTER COLUMN "options" DROP DEFAULT` - ); - await queryRunner.query( - `CREATE INDEX "IDX_b3d70227bb45dd8060e256ee33" ON "interactions" ("procuration") ` - ); - } - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "public"."IDX_b3d70227bb45dd8060e256ee33"` - ); - } -} diff --git a/packages/backend/src/_migrations/1701901668716-auto-migration.ts b/packages/backend/src/_migrations/1701901668716-auto-migration.ts deleted file mode 100644 index b1c2aad20f..0000000000 --- a/packages/backend/src/_migrations/1701901668716-auto-migration.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AutoMigration1701901668716 implements MigrationInterface { - name = "AutoMigration1701901668716"; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "structure" ALTER COLUMN "options" SET DEFAULT '{"numeroBoite": true, "surnom": false}'` - ); - await queryRunner.query( - `UPDATE "structure" SET options = jsonb_set(options, '{surnom}', 'false', true)` - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "usager" ALTER COLUMN "telephone" SET DEFAULT '{"numero": "", "countryCode": "fr"}'` - ); - } -} diff --git a/packages/backend/src/_migrations/1702480247859-auto-migration.ts b/packages/backend/src/_migrations/1702480247859-auto-migration.ts new file mode 100644 index 0000000000..59ffb1ff61 --- /dev/null +++ b/packages/backend/src/_migrations/1702480247859-auto-migration.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AutoMigration1702480247859 implements MigrationInterface { + name = "AutoMigration1702480247859"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "open_data_places" ADD "mail" text`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "open_data_places" DROP COLUMN "mail"` + ); + } +} diff --git a/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts b/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts index 4a6e65df36..134fb77986 100644 --- a/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts +++ b/packages/backend/src/database/entities/open-data-place/OpenDataPlaceTable.typeorm.ts @@ -51,6 +51,9 @@ export class OpenDataPlaceTable extends AppTypeormTable { @JoinColumn({ name: "structureId", referencedColumnName: "id" }) structureId: number; + @Column({ type: "text", nullable: true }) + mail: string; + public constructor(entity?: Partial) { super(entity); Object.assign(this, entity); diff --git a/packages/backend/src/open-data-places/load-soliguide.ts b/packages/backend/src/open-data-places/load-soliguide.ts index ad4e1a52ed..4efb5c4449 100644 --- a/packages/backend/src/open-data-places/load-soliguide.ts +++ b/packages/backend/src/open-data-places/load-soliguide.ts @@ -75,6 +75,7 @@ const getFromSoliguide = async () => { longitude: place.position.location.coordinates[0], source: "soliguide", uniqueId: place.lieu_id.toString(), + mail: place?.entity?.mail?.toString(), }) ); }