diff --git a/api/src/mutations/mint.rs b/api/src/mutations/mint.rs index 2ecbafb..0dcbd63 100644 --- a/api/src/mutations/mint.rs +++ b/api/src/mutations/mint.rs @@ -1162,7 +1162,6 @@ impl Mutation { let mint = CollectionMints::find() .filter(collection_mints::Column::CollectionId.eq(drop.collection_id)) .filter(collection_mints::Column::CreationStatus.eq(CreationStatus::Queued)) - .order_by(SimpleExpr::FunctionCall(Func::random()), Order::Asc) .one(conn) .await? .ok_or(Error::new("No Queued mint found for the drop"))?; diff --git a/migration/src/lib.rs b/migration/src/lib.rs index a778326..0b8704a 100644 --- a/migration/src/lib.rs +++ b/migration/src/lib.rs @@ -60,6 +60,7 @@ mod m20230911_144938_make_compressed_column_optional; mod m20230914_154759_add_job_trackings_table; mod m20230915_111128_create_mints_creation_status_idx; mod m20230922_150621_nullable_metadata_jsons_identifier_and_uri; +mod m20231011_202917_create_queued_mints_idx; pub struct Migrator; @@ -127,6 +128,7 @@ impl MigratorTrait for Migrator { Box::new(m20230915_111128_create_mints_creation_status_idx::Migration), Box::new(m20230914_154759_add_job_trackings_table::Migration), Box::new(m20230922_150621_nullable_metadata_jsons_identifier_and_uri::Migration), + Box::new(m20231011_202917_create_queued_mints_idx::Migration), ] } } diff --git a/migration/src/m20231011_202917_create_queued_mints_idx.rs b/migration/src/m20231011_202917_create_queued_mints_idx.rs new file mode 100644 index 0000000..61f1589 --- /dev/null +++ b/migration/src/m20231011_202917_create_queued_mints_idx.rs @@ -0,0 +1,29 @@ +use sea_orm_migration::{ + prelude::*, + sea_orm::{ConnectionTrait, Statement}, +}; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + let db = manager.get_connection(); + + let stmt = Statement::from_string( + manager.get_database_backend(), + r#"CREATE INDEX IF NOT EXISTS queued_mints_idx ON collection_mints(creation_status) + where creation_status = 'queued';"# + .to_string(), + ); + + db.execute(stmt).await?; + + Ok(()) + } + + async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { + Ok(()) + } +}