-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/send-notificatio…
…n-permission
- Loading branch information
Showing
4 changed files
with
37 additions
and
11 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
24 changes: 24 additions & 0 deletions
24
src/migrations/0014_permissions_set_addresses_lowercase.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,24 @@ | ||
import { Migration, MigratorComponents, PermissionType } from '../types' | ||
import SQL from 'sql-template-strings' | ||
|
||
export const migration: Migration = { | ||
id: '0014_permissions_set_addresses_lowercase', | ||
run: async (components: Pick<MigratorComponents, 'database' | 'nameOwnership' | 'storage' | 'worldsManager'>) => { | ||
const worlds = await components.database.query('SELECT name, permissions FROM worlds ORDER BY name') | ||
|
||
for (const world of worlds.rows) { | ||
const permissions = world.permissions | ||
for (const permissionType of Object.keys(permissions)) { | ||
const permission = permissions[permissionType] | ||
if (permission.type === PermissionType.AllowList) { | ||
permission.wallets = permission.wallets.map((address: string) => address.toLowerCase()) | ||
} | ||
} | ||
|
||
await components.database.query(SQL` | ||
UPDATE worlds | ||
SET permissions = ${JSON.stringify(permissions)}::json | ||
WHERE name = ${world.name}`) | ||
} | ||
} | ||
} |
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