1use collections::{HashMap, HashSet};
2use gpui::{App, Entity, SharedString};
3use std::path::PathBuf;
4
5use db::{
6 query,
7 sqlez::{domain::Domain, thread_safe_connection::ThreadSafeConnection},
8 sqlez_macros::sql,
9};
10
11use crate::{
12 trusted_worktrees::{PathTrust, RemoteHostLocation, find_worktree_in_store},
13 worktree_store::WorktreeStore,
14};
15
16// https://www.sqlite.org/limits.html
17// > <..> the maximum value of a host parameter number is SQLITE_MAX_VARIABLE_NUMBER,
18// > which defaults to <..> 32766 for SQLite versions after 3.32.0.
19#[allow(unused)]
20const MAX_QUERY_PLACEHOLDERS: usize = 32000;
21
22#[allow(unused)]
23pub struct ProjectDb(ThreadSafeConnection);
24
25impl Domain for ProjectDb {
26 const NAME: &str = stringify!(ProjectDb);
27
28 const MIGRATIONS: &[&str] = &[sql!(
29 CREATE TABLE IF NOT EXISTS trusted_worktrees (
30 trust_id INTEGER PRIMARY KEY AUTOINCREMENT,
31 absolute_path TEXT,
32 user_name TEXT,
33 host_name TEXT
34 ) STRICT;
35 )];
36}
37
38db::static_connection!(PROJECT_DB, ProjectDb, []);
39
40impl ProjectDb {}
41
42#[cfg(test)]
43mod tests {
44 use std::path::PathBuf;
45
46 use collections::{HashMap, HashSet};
47 use gpui::{SharedString, TestAppContext};
48 use serde_json::json;
49 use settings::SettingsStore;
50 use smol::lock::Mutex;
51 use util::path;
52
53 use crate::{
54 FakeFs, Project,
55 persistence::PROJECT_DB,
56 trusted_worktrees::{PathTrust, RemoteHostLocation},
57 };
58
59 static TEST_WORKTREE_TRUST_LOCK: Mutex<()> = Mutex::new(());
60}