This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add migration for lower-casing addresses in storage (#448)
- Loading branch information
Showing
3 changed files
with
25 additions
and
3 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
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
22 changes: 22 additions & 0 deletions
22
src/migrations/scripts/1607591688470-lower-case-address-columns.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,22 @@ | ||
import { QueryInterface } from 'sequelize' | ||
import { Sequelize } from 'sequelize-typescript' | ||
|
||
export default { | ||
// eslint-disable-next-line require-await | ||
async up (queryInterface: QueryInterface, sequelize: Sequelize): Promise<void> { | ||
const transaction = await sequelize.transaction() | ||
try { | ||
await sequelize.query('UPDATE storage_offer SET provider = lower(provider)', { transaction }) | ||
await sequelize.query('UPDATE "storage_billing-plan" SET tokenAddress = lower(tokenAddress), offerId = lower(offerId)', { transaction }) | ||
await sequelize.query('UPDATE storage_agreement SET consumer = lower(consumer), tokenAddress = lower(tokenAddress), offerId = lower(offerId)', { transaction }) | ||
await sequelize.query('UPDATE storage_stakes SET account = lower(account), token = lower(token)', { transaction }) | ||
|
||
await transaction.commit() | ||
} catch (e) { | ||
await transaction.rollback() | ||
} | ||
}, | ||
// Lower-casing can not be restored | ||
// eslint-disable-next-line require-await,@typescript-eslint/no-empty-function | ||
async down (queryInterface: QueryInterface, sequelize: Sequelize): Promise<void> {} | ||
} |