Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2/2][FA migration] Complete fa migration and rename table #494

Merged
merged 3 commits into from
Aug 30, 2024

Conversation

bowenyang007
Copy link
Collaborator

@bowenyang007 bowenyang007 commented Aug 28, 2024

  1. Swap Hasura to use current_unified_fungible_asset_balances
  2. Add a killswitch on current_unified_fungible_asset_balances_to_be_renamed
    1. In addition, make a migration dropping columns. We want to split dropping columns separately from adding columns back so that we can add the columns without going through diesel migration again.
    2. Deploy the change with KS turned on. This should create no downtime since column dropping is quick.

[This PR]
3. Add generated columns back in dbeaver
4. Create new migration with added columns. Then remove KS.
5. Rename current_fungible_asset_balances to current_fungible_asset_balances_legacy
6. Rename current_unified_fungible_asset_balances_to_be_renamed to current_fungible_asset_balances

@bowenyang007 bowenyang007 requested a review from rtso August 28, 2024 02:52
@bowenyang007 bowenyang007 changed the title [1/2][FA migration] Complete fa migration and rename table [2/2][FA migration] Complete fa migration and rename table Aug 28, 2024
last_transaction_timestamp -> Nullable<Timestamp>,
inserted_at -> Timestamp,
#[max_length = 1000]
asset_type -> Nullable<Varchar>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be nullable

is_frozen -> Bool,
amount_v1 -> Nullable<Numeric>,
amount_v2 -> Nullable<Numeric>,
amount -> Nullable<Numeric>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be nullable

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced offline, this will be fixed in next PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't related to this PR. only popped up due to renaming table. We'll address it next PR.

asset_type_v2 -> Nullable<Varchar>,
#[max_length = 1000]
asset_type_v1 -> Nullable<Varchar>,
is_primary -> Nullable<Bool>,
Copy link
Collaborator

@rtso rtso Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be nullable to match with the legacy schema

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced offline, this will be fixed in next PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't related to this PR. only popped up due to renaming table. We'll address it next PR.

#[max_length = 1000]
asset_type -> Nullable<Varchar>,
#[max_length = 10]
token_standard -> Nullable<Varchar>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be nullable either

@@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to redo this migration because it has already been applied to the mainnet and testnet db.

asset_type_v2 -> Nullable<Varchar>,
#[max_length = 1000]
asset_type_v1 -> Nullable<Varchar>,
is_primary -> Nullable<Bool>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced offline, this will be fixed in next PR

is_frozen -> Bool,
amount_v1 -> Nullable<Numeric>,
amount_v2 -> Nullable<Numeric>,
amount -> Nullable<Numeric>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synced offline, this will be fixed in next PR

@bowenyang007 bowenyang007 merged commit b04bc68 into main Aug 30, 2024
7 of 8 checks passed
@bowenyang007 bowenyang007 deleted the fa_migration_2 branch August 30, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants