Skip to content

Commit

Permalink
fix: add migration to add listing approval permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan committed Oct 19, 2023
1 parent 9fc3ab6 commit b0f398a
Showing 1 changed file with 29 additions and 0 deletions.
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
}
}

0 comments on commit b0f398a

Please sign in to comment.