-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2/2][FA migration] Complete fa migration and rename table (#494)
* complete fa migration and rename table * add index back * set fields to nonnull
- Loading branch information
1 parent
fc65c59
commit b04bc68
Showing
5 changed files
with
68 additions
and
40 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
7 changes: 7 additions & 0 deletions
7
rust/processor/src/db/postgres/migrations/2024-08-28-015552_fa_migration_fix_2/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,7 @@ | ||
-- This file should undo anything in `up.sql` | ||
ALTER TABLE current_fungible_asset_balances | ||
RENAME TO current_unified_fungible_asset_balances_to_be_renamed; | ||
ALTER TABLE current_fungible_asset_balances_legacy | ||
RENAME TO current_fungible_asset_balances; | ||
ALTER TABLE current_unified_fungible_asset_balances_to_be_renamed DROP COLUMN IF EXISTS asset_type; | ||
ALTER TABLE current_unified_fungible_asset_balances_to_be_renamed DROP COLUMN IF EXISTS token_standard; |
15 changes: 15 additions & 0 deletions
15
rust/processor/src/db/postgres/migrations/2024-08-28-015552_fa_migration_fix_2/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 | ||
ALTER TABLE current_unified_fungible_asset_balances_to_be_renamed | ||
ADD COLUMN IF NOT EXISTS asset_type VARCHAR(1000) NOT NULL GENERATED ALWAYS AS (COALESCE(asset_type_v1, asset_type_v2)) STORED; | ||
CREATE INDEX IF NOT EXISTS cufab_owner_at_index ON current_unified_fungible_asset_balances_to_be_renamed (owner_address, asset_type); | ||
ALTER TABLE current_unified_fungible_asset_balances_to_be_renamed | ||
ADD COLUMN IF NOT EXISTS token_standard VARCHAR(10) NOT NULL GENERATED ALWAYS AS ( | ||
CASE | ||
WHEN asset_type_v1 IS NOT NULL THEN 'v1' | ||
ELSE 'v2' | ||
END | ||
) STORED; | ||
ALTER TABLE current_fungible_asset_balances | ||
RENAME TO current_fungible_asset_balances_legacy; | ||
ALTER TABLE current_unified_fungible_asset_balances_to_be_renamed | ||
RENAME TO current_fungible_asset_balances; |
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