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

add missing index for token_accounts table #243

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mod m20240320_120101_add_mpl_core_info_items;
mod m20240520_120101_add_mpl_core_external_plugins_columns;
mod m20240718_161232_change_supply_columns_to_numeric;
mod m20241119_060310_add_token_inscription_enum_variant;
mod m20250213_053451_add_idx_token_accounts_owner;

pub mod model;

Expand Down Expand Up @@ -99,6 +100,7 @@ impl MigratorTrait for Migrator {
Box::new(m20240520_120101_add_mpl_core_external_plugins_columns::Migration),
Box::new(m20240718_161232_change_supply_columns_to_numeric::Migration),
Box::new(m20241119_060310_add_token_inscription_enum_variant::Migration),
Box::new(m20250213_053451_add_idx_token_accounts_owner::Migration),
]
}
}
35 changes: 35 additions & 0 deletions migration/src/m20250213_053451_add_idx_token_accounts_owner.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use super::model::table::TokenAccounts;
use sea_orm::{ConnectionTrait, DatabaseBackend, Statement};
use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let conn = manager.get_connection();

conn.execute(Statement::from_string(
DatabaseBackend::Postgres,
"CREATE INDEX CONCURRENTLY IF NOT EXISTS token_accounts_owner_idx ON token_accounts (owner);"
.to_string(),
))
.await?;

Ok(())
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_index(
Index::drop()
.name("token_accounts_owner_idx")
.table(TokenAccounts::Table)
.to_owned(),
)
.await?;

Ok(())
}
}
Loading