-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify current_unified_fungible_asset_balances for smoother migration…
… later (#406) * modify current unified fungible asset balances for migration * fix typo
- Loading branch information
1 parent
f7808ad
commit 88b0dbe
Showing
5 changed files
with
52 additions
and
30 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
13 changes: 13 additions & 0 deletions
13
...ostgres/migrations/2024-06-13-065302_current_unified_fungible_asset_balance_edit/down.sql
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,13 @@ | ||
-- This file should undo anything in `up.sql` | ||
ALTER TABLE current_unified_fungible_asset_balances_to_be_renamed | ||
RENAME TO current_unified_fungible_asset_balances; | ||
DROP INDEX IF EXISTS cufab_owner_at_index; | ||
ALTER TABLE current_unified_fungible_asset_balances DROP COLUMN asset_type; | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
RENAME COLUMN asset_type_v2 TO asset_type; | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
RENAME COLUMN asset_type_v1 TO coin_type; | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
ALTER COLUMN asset_type | ||
SET NOT NULL; | ||
CREATE INDEX IF NOT EXISTS cufab_owner_at_index ON current_unified_fungible_asset_balances (owner_address, asset_type); |
15 changes: 15 additions & 0 deletions
15
.../postgres/migrations/2024-06-13-065302_current_unified_fungible_asset_balance_edit/up.sql
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,15 @@ | ||
-- Your SQL goes here | ||
-- Rename asset_type and coin_type to v1 and v2, and make a generated asset_type to be v2 if exists, else v1. | ||
DROP INDEX IF EXISTS cufab_owner_at_index; | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
ALTER COLUMN asset_type DROP NOT NULL; | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
RENAME COLUMN asset_type TO asset_type_v2; | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
RENAME COLUMN coin_type TO asset_type_v1; | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
ADD COLUMN asset_type VARCHAR(1000) GENERATED ALWAYS AS (COALESCE(asset_type_v2, asset_type_v1)) STORED; | ||
CREATE INDEX IF NOT EXISTS cufab_owner_at_index ON current_unified_fungible_asset_balances (owner_address, asset_type); | ||
-- Rename table to set expectation that we'll rename this table to current_fungible_asset_balances after testing | ||
ALTER TABLE current_unified_fungible_asset_balances | ||
RENAME TO current_unified_fungible_asset_balances_to_be_renamed; |
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