Migrate to the new entity format

This commit is contained in:
2025-11-02 11:04:19 -07:00
parent 508c4ed32f
commit c5475585d4
69 changed files with 2815 additions and 4038 deletions
+13 -3
View File
@@ -9,9 +9,12 @@ pub struct Connection(DatabaseConnection);
impl Connection {
/// Helper function for applying database migrations while wrapping a
/// [DatabaseConnection] in a newtype
pub async fn try_from(database: DatabaseConnection) -> Result<Self, DbErr> {
crate::migration::Migrator::up(&database, None).await?;
Ok(Self(database))
pub async fn try_from(db: DatabaseConnection) -> Result<Self, DbErr> {
crate::migration::Migrator::down(&db, None).await?;
db.get_schema_registry("flix_db::*").sync(&db).await?;
db.get_schema_registry("flix_db::*").sync(&db).await?;
crate::migration::Migrator::up(&db, None).await?;
Ok(Self(db))
}
}
@@ -20,3 +23,10 @@ impl AsRef<DatabaseConnection> for Connection {
&self.0
}
}
#[cfg(test)]
impl Connection {
pub(crate) fn take(self) -> DatabaseConnection {
self.0
}
}