-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
35 changes: 35 additions & 0 deletions
35
packages/backend/src/_migrations/1727186783887-manual-migration.ts
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,35 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class ManualMigration1727186783887 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// Compter le nombre d'enregistrements qui seront affectés | ||
const countResult = await queryRunner.query(` | ||
SELECT COUNT(*) as count | ||
FROM usager | ||
WHERE statut != 'RADIE' AND options->'npai'->>'actif' = 'true'; | ||
`); | ||
|
||
const count = parseInt(countResult[0].count); | ||
|
||
console.log(`Nombre d'enregistrements qui seront mis à jour : ${count}`); | ||
|
||
// Exécuter la mise à jour | ||
await queryRunner.query(` | ||
UPDATE usager | ||
SET options = jsonb_set( | ||
options, | ||
'{npai}', | ||
'{"actif": false, "dateDebut": null}'::jsonb, | ||
true | ||
) | ||
WHERE statut != 'RADIE' AND options->'npai'->>'actif' = 'true'; | ||
`); | ||
|
||
console.log( | ||
`Mise à jour terminée. ${count} enregistrements ont été modifiés.` | ||
); | ||
} | ||
|
||
public async down(): Promise<void> {} | ||
} |
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