forked from bloom-housing/bloom
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add migration to add listing approval permissions (#648)
- Loading branch information
1 parent
e2e3e7b
commit f2b899f
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
backend/core/src/migration/1697654611220-turn-on-listing-approval.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,30 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
import { EnumJurisdictionListingApprovalPermissions } from "../../types" | ||
|
||
export class turnOnListingApproval1697654611220 implements MigrationInterface { | ||
name = "turnOnListingApproval1697654611220" | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const jurisdictions: { id: string }[] = await queryRunner.query(` | ||
SELECT id | ||
FROM jurisdictions | ||
`) | ||
|
||
const approvalPermissions = [ | ||
EnumJurisdictionListingApprovalPermissions.admin, | ||
EnumJurisdictionListingApprovalPermissions.jurisdictionAdmin, | ||
].map((permission) => `'${permission}'::jurisdictions_listing_approval_permissions_enum`) | ||
|
||
jurisdictions.forEach(async (jurisdictionId) => { | ||
await queryRunner.query(` | ||
UPDATE jurisdictions | ||
SET listing_approval_permissions = ARRAY [${approvalPermissions}] | ||
WHERE id = '${jurisdictionId.id}' | ||
`) | ||
}) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
// no down migration | ||
} | ||
} |