mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: reload UI (#2999)
* chore: reload folder * chore: reload folder * chore: init sync * chore: update tables * chore: update database * chore: load row * chore: update * chore: reload row * test: fit test * chore: retry * chore: support batch fetch * chore: enable sync * chore: sync switch * chore: sync switch * chore: migration user data * chore: migrate data * chore: migrate folder * chore: save user email * chore: refresh user profile * chore: fix test * chore: delete translation files * test: clippy format
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE user_table
|
||||
DROP COLUMN auth_type;
|
@ -0,0 +1,3 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE user_table
|
||||
ADD COLUMN auth_type INTEGER NOT NULL DEFAULT 0;
|
@ -27,14 +27,13 @@ pub mod prelude {
|
||||
pub use diesel::{query_dsl::*, BelongingToDsl, ExpressionMethods, RunQueryDsl};
|
||||
|
||||
pub use crate::*;
|
||||
|
||||
pub use super::UserDatabaseConnection;
|
||||
}
|
||||
|
||||
embed_migrations!("../flowy-sqlite/migrations/");
|
||||
pub const DB_NAME: &str = "flowy-database.db";
|
||||
|
||||
pub fn init(storage_path: &str) -> Result<Database, io::Error> {
|
||||
pub fn init<P: AsRef<Path>>(storage_path: P) -> Result<Database, io::Error> {
|
||||
let storage_path = storage_path.as_ref().to_str().unwrap();
|
||||
if !Path::new(storage_path).exists() {
|
||||
std::fs::create_dir_all(storage_path)?;
|
||||
}
|
||||
@ -52,7 +51,3 @@ where
|
||||
let msg = format!("{:?}", e);
|
||||
io::Error::new(io::ErrorKind::NotConnected, msg)
|
||||
}
|
||||
|
||||
pub trait UserDatabaseConnection: Send + Sync {
|
||||
fn get_connection(&self) -> Result<DBConnection, String>;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ diesel::table! {
|
||||
openai_key -> Text,
|
||||
token -> Text,
|
||||
email -> Text,
|
||||
auth_type -> Integer,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,10 @@
|
||||
use crate::sqlite::{errors::*, pragma::*};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use diesel::{connection::Connection, SqliteConnection};
|
||||
use r2d2::{CustomizeConnection, ManageConnection, Pool};
|
||||
use scheduled_thread_pool::ScheduledThreadPool;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref DB_POOL: Arc<ScheduledThreadPool> = Arc::new(
|
||||
ScheduledThreadPool::builder().num_threads(4).thread_name_pattern("db-pool-{}:").build()
|
||||
);
|
||||
}
|
||||
use crate::sqlite::{errors::*, pragma::*};
|
||||
|
||||
pub struct ConnectionPool {
|
||||
pub(crate) inner: Pool<ConnectionManager>,
|
||||
@ -28,7 +24,12 @@ impl ConnectionPool {
|
||||
T: Into<String>,
|
||||
{
|
||||
let manager = ConnectionManager::new(uri);
|
||||
let thread_pool = DB_POOL.clone();
|
||||
let thread_pool = Arc::new(
|
||||
ScheduledThreadPool::builder()
|
||||
.num_threads(4)
|
||||
.thread_name_pattern("db-pool-{}:")
|
||||
.build(),
|
||||
);
|
||||
let config = Arc::new(config);
|
||||
let customizer_config = DatabaseCustomizerConfig::default();
|
||||
|
||||
|
Reference in New Issue
Block a user