You've already forked flix
Migrate to the new entity format
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user