Compare commits

...

2 Commits

Author SHA1 Message Date
Akulij
6f24d92215 drop all previous indexes in migration 2025-04-30 18:08:27 +03:00
Akulij
4d6717967d create AnyCollection type in migration
reason: most of it doesn't need real type,
but will simplificate alot without real ones
2025-04-30 18:07:07 +03:00

View File

@ -122,6 +122,12 @@ impl DB {
} }
pub async fn migrate(&mut self) -> DbResult<()> { pub async fn migrate(&mut self) -> DbResult<()> {
let db = self.get_database().await;
/// some migrations doesn't realy need type of collection
type AnyCollection = Event;
db.collection::<AnyCollection>("events")
.drop_indexes()
.await?;
let events = self.get_database().await.collection::<Event>("events"); let events = self.get_database().await.collection::<Event>("events");
events events
.create_index( .create_index(
@ -132,12 +138,15 @@ impl DB {
) )
.await?; .await?;
db.collection::<AnyCollection>("events")
.drop_indexes()
.await?;
// clear callbacks after a day because otherwise database will contain so much data // clear callbacks after a day because otherwise database will contain so much data
// for just button clicks // for just button clicks
let callback_info = self let callback_info = self
.get_database() .get_database()
.await .await
.collection::<Event>("callback_info"); .collection::<AnyCollection>("callback_info");
callback_info callback_info
.create_index( .create_index(
IndexModel::builder() IndexModel::builder()