feat!: unified migration logic in server electron, and browser (#4079)

Co-authored-by: Mirone <Saul-Mirone@outlook.com>
This commit is contained in:
Alex Yang
2023-09-06 00:44:53 -07:00
committed by GitHub
parent 925c18300f
commit 1b6a78cd00
61 changed files with 10776 additions and 10267 deletions

View File

@@ -78,6 +78,7 @@ export class SqliteConnection {
): Promise<void>;
initVersion(): Promise<void>;
setVersion(version: number): Promise<void>;
getMaxVersion(): Promise<number>;
close(): Promise<void>;
get isClose(): boolean;
static validate(path: string): Promise<ValidationResult>;

View File

@@ -8,7 +8,7 @@ use sqlx::{
};
// latest version
const LATEST_VERSION: i32 = 3;
const LATEST_VERSION: i32 = 4;
#[napi(object)]
pub struct BlobRow {
@@ -265,6 +265,17 @@ impl SqliteConnection {
Ok(())
}
#[napi]
pub async fn get_max_version(&self) -> napi::Result<i32> {
// 4 is the current version
let version = sqlx::query!("SELECT COALESCE(MAX(version), 4) AS max_version FROM version_info")
.fetch_one(&self.pool)
.await
.map_err(anyhow::Error::from)?
.max_version;
Ok(version)
}
#[napi]
pub async fn close(&self) {
self.pool.close().await;