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
- Loading branch information
1 parent
9fc3ab6
commit b0f398a
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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, | ||
].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 | ||
} | ||
} |