Browse Source
			
			
			
			
				
		* Use Diesels MultiConnections Derive With this PR we remove almost all custom macro's to create the multiple database type code. This is now handled by Diesel it self. This removed the need of the following functions/macro's: - `db_object!` - `::to_db` - `.from_db()` It is also possible to just use one schema instead of multiple per type. Also done: - Refactored the SQLite backup function - Some formatting of queries so every call is one a separate line, this looks a bit better - Declare `conn` as mut inside each `db_run!` instead of having to declare it as `mut` in functions or calls - Added an `ACTIVE_DB_TYPE` static which holds the currently active database type - Removed `diesel_logger` crate and use Diesel's `set_default_instrumentation()` If you want debug queries you can now simply change the log level of `vaultwarden::db::query_logger` - Use PostgreSQL v17 in the Alpine images to match the Debian Trixie version - Optimized the Workflows since `diesel_logger` isn't needed anymore And on the extra plus-side, this lowers the compile-time and binary size too. Signed-off-by: BlackDex <black.dex@gmail.com> * Adjust query_logger and some other small items Signed-off-by: BlackDex <black.dex@gmail.com> * Remove macro, replaced with an function Signed-off-by: BlackDex <black.dex@gmail.com> * Implement custom connection manager Signed-off-by: BlackDex <black.dex@gmail.com> * Updated some crates to keep up2date Signed-off-by: BlackDex <black.dex@gmail.com> * Small adjustment Signed-off-by: BlackDex <black.dex@gmail.com> * crate updates Signed-off-by: BlackDex <black.dex@gmail.com> * Update crates Signed-off-by: BlackDex <black.dex@gmail.com> --------- Signed-off-by: BlackDex <black.dex@gmail.com>main
							committed by
							
								 GitHub
								GitHub
							
						
					
				
				 61 changed files with 3219 additions and 4213 deletions
			
			
		
								
									
										File diff suppressed because it is too large
									
								
							
						
					
								
									
										File diff suppressed because it is too large
									
								
							
						
					| @ -0,0 +1,57 @@ | |||
| use diesel::connection::{Instrumentation, InstrumentationEvent}; | |||
| use std::{cell::RefCell, collections::HashMap, time::Instant}; | |||
| 
 | |||
| thread_local! { | |||
|     static QUERY_PERF_TRACKER: RefCell<HashMap<String, Instant>> = RefCell::new(HashMap::new()); | |||
| } | |||
| 
 | |||
| pub fn simple_logger() -> Option<Box<dyn Instrumentation>> { | |||
|     Some(Box::new(|event: InstrumentationEvent<'_>| match event { | |||
|         InstrumentationEvent::StartEstablishConnection { | |||
|             url, | |||
|             .. | |||
|         } => { | |||
|             debug!("Establishing connection: {url}") | |||
|         } | |||
|         InstrumentationEvent::FinishEstablishConnection { | |||
|             url, | |||
|             error, | |||
|             .. | |||
|         } => { | |||
|             if let Some(e) = error { | |||
|                 error!("Error during establishing a connection with {url}: {e:?}") | |||
|             } else { | |||
|                 debug!("Connection established: {url}") | |||
|             } | |||
|         } | |||
|         InstrumentationEvent::StartQuery { | |||
|             query, | |||
|             .. | |||
|         } => { | |||
|             let query_string = format!("{query:?}"); | |||
|             let start = Instant::now(); | |||
|             QUERY_PERF_TRACKER.with_borrow_mut(|map| { | |||
|                 map.insert(query_string, start); | |||
|             }); | |||
|         } | |||
|         InstrumentationEvent::FinishQuery { | |||
|             query, | |||
|             .. | |||
|         } => { | |||
|             let query_string = format!("{query:?}"); | |||
|             QUERY_PERF_TRACKER.with_borrow_mut(|map| { | |||
|                 if let Some(start) = map.remove(&query_string) { | |||
|                     let duration = start.elapsed(); | |||
|                     if duration.as_secs() >= 5 { | |||
|                         warn!("SLOW QUERY [{:.2}s]: {}", duration.as_secs_f32(), query_string); | |||
|                     } else if duration.as_secs() >= 1 { | |||
|                         info!("SLOW QUERY [{:.2}s]: {}", duration.as_secs_f32(), query_string); | |||
|                     } else { | |||
|                         debug!("QUERY [{:?}]: {}", duration, query_string); | |||
|                     } | |||
|                 } | |||
|             }); | |||
|         } | |||
|         _ => {} | |||
|     })) | |||
| } | |||
| @ -1,395 +0,0 @@ | |||
| table! { | |||
|     attachments (id) { | |||
|         id -> Text, | |||
|         cipher_uuid -> Text, | |||
|         file_name -> Text, | |||
|         file_size -> BigInt, | |||
|         akey -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     ciphers (uuid) { | |||
|         uuid -> Text, | |||
|         created_at -> Datetime, | |||
|         updated_at -> Datetime, | |||
|         user_uuid -> Nullable<Text>, | |||
|         organization_uuid -> Nullable<Text>, | |||
|         key -> Nullable<Text>, | |||
|         atype -> Integer, | |||
|         name -> Text, | |||
|         notes -> Nullable<Text>, | |||
|         fields -> Nullable<Text>, | |||
|         data -> Text, | |||
|         password_history -> Nullable<Text>, | |||
|         deleted_at -> Nullable<Datetime>, | |||
|         reprompt -> Nullable<Integer>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     ciphers_collections (cipher_uuid, collection_uuid) { | |||
|         cipher_uuid -> Text, | |||
|         collection_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     collections (uuid) { | |||
|         uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         name -> Text, | |||
|         external_id -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     devices (uuid, user_uuid) { | |||
|         uuid -> Text, | |||
|         created_at -> Datetime, | |||
|         updated_at -> Datetime, | |||
|         user_uuid -> Text, | |||
|         name -> Text, | |||
|         atype -> Integer, | |||
|         push_uuid -> Nullable<Text>, | |||
|         push_token -> Nullable<Text>, | |||
|         refresh_token -> Text, | |||
|         twofactor_remember -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     event (uuid) { | |||
|         uuid -> Varchar, | |||
|         event_type -> Integer, | |||
|         user_uuid -> Nullable<Varchar>, | |||
|         org_uuid -> Nullable<Varchar>, | |||
|         cipher_uuid -> Nullable<Varchar>, | |||
|         collection_uuid -> Nullable<Varchar>, | |||
|         group_uuid -> Nullable<Varchar>, | |||
|         org_user_uuid -> Nullable<Varchar>, | |||
|         act_user_uuid -> Nullable<Varchar>, | |||
|         device_type -> Nullable<Integer>, | |||
|         ip_address -> Nullable<Text>, | |||
|         event_date -> Timestamp, | |||
|         policy_uuid -> Nullable<Varchar>, | |||
|         provider_uuid -> Nullable<Varchar>, | |||
|         provider_user_uuid -> Nullable<Varchar>, | |||
|         provider_org_uuid -> Nullable<Varchar>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     favorites (user_uuid, cipher_uuid) { | |||
|         user_uuid -> Text, | |||
|         cipher_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     folders (uuid) { | |||
|         uuid -> Text, | |||
|         created_at -> Datetime, | |||
|         updated_at -> Datetime, | |||
|         user_uuid -> Text, | |||
|         name -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     folders_ciphers (cipher_uuid, folder_uuid) { | |||
|         cipher_uuid -> Text, | |||
|         folder_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     invitations (email) { | |||
|         email -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     org_policies (uuid) { | |||
|         uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         atype -> Integer, | |||
|         enabled -> Bool, | |||
|         data -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     organizations (uuid) { | |||
|         uuid -> Text, | |||
|         name -> Text, | |||
|         billing_email -> Text, | |||
|         private_key -> Nullable<Text>, | |||
|         public_key -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     sends (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Nullable<Text>, | |||
|         organization_uuid -> Nullable<Text>, | |||
|         name -> Text, | |||
|         notes -> Nullable<Text>, | |||
|         atype -> Integer, | |||
|         data -> Text, | |||
|         akey -> Text, | |||
|         password_hash -> Nullable<Binary>, | |||
|         password_salt -> Nullable<Binary>, | |||
|         password_iter -> Nullable<Integer>, | |||
|         max_access_count -> Nullable<Integer>, | |||
|         access_count -> Integer, | |||
|         creation_date -> Datetime, | |||
|         revision_date -> Datetime, | |||
|         expiration_date -> Nullable<Datetime>, | |||
|         deletion_date -> Datetime, | |||
|         disabled -> Bool, | |||
|         hide_email -> Nullable<Bool>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     twofactor (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Text, | |||
|         atype -> Integer, | |||
|         enabled -> Bool, | |||
|         data -> Text, | |||
|         last_used -> BigInt, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     twofactor_incomplete (user_uuid, device_uuid) { | |||
|         user_uuid -> Text, | |||
|         device_uuid -> Text, | |||
|         device_name -> Text, | |||
|         device_type -> Integer, | |||
|         login_time -> Timestamp, | |||
|         ip_address -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     twofactor_duo_ctx (state) { | |||
|         state -> Text, | |||
|         user_email -> Text, | |||
|         nonce -> Text, | |||
|         exp -> BigInt, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     users (uuid) { | |||
|         uuid -> Text, | |||
|         enabled -> Bool, | |||
|         created_at -> Datetime, | |||
|         updated_at -> Datetime, | |||
|         verified_at -> Nullable<Datetime>, | |||
|         last_verifying_at -> Nullable<Datetime>, | |||
|         login_verify_count -> Integer, | |||
|         email -> Text, | |||
|         email_new -> Nullable<Text>, | |||
|         email_new_token -> Nullable<Text>, | |||
|         name -> Text, | |||
|         password_hash -> Binary, | |||
|         salt -> Binary, | |||
|         password_iterations -> Integer, | |||
|         password_hint -> Nullable<Text>, | |||
|         akey -> Text, | |||
|         private_key -> Nullable<Text>, | |||
|         public_key -> Nullable<Text>, | |||
|         totp_secret -> Nullable<Text>, | |||
|         totp_recover -> Nullable<Text>, | |||
|         security_stamp -> Text, | |||
|         stamp_exception -> Nullable<Text>, | |||
|         equivalent_domains -> Text, | |||
|         excluded_globals -> Text, | |||
|         client_kdf_type -> Integer, | |||
|         client_kdf_iter -> Integer, | |||
|         client_kdf_memory -> Nullable<Integer>, | |||
|         client_kdf_parallelism -> Nullable<Integer>, | |||
|         api_key -> Nullable<Text>, | |||
|         avatar_color -> Nullable<Text>, | |||
|         external_id -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     users_collections (user_uuid, collection_uuid) { | |||
|         user_uuid -> Text, | |||
|         collection_uuid -> Text, | |||
|         read_only -> Bool, | |||
|         hide_passwords -> Bool, | |||
|         manage -> Bool, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     users_organizations (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         invited_by_email -> Nullable<Text>, | |||
|         access_all -> Bool, | |||
|         akey -> Text, | |||
|         status -> Integer, | |||
|         atype -> Integer, | |||
|         reset_password_key -> Nullable<Text>, | |||
|         external_id -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     organization_api_key (uuid, org_uuid) { | |||
|         uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         atype -> Integer, | |||
|         api_key -> Text, | |||
|         revision_date -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     sso_nonce (state) { | |||
|         state -> Text, | |||
|         nonce -> Text, | |||
|         verifier -> Nullable<Text>, | |||
|         redirect_uri -> Text, | |||
|         created_at -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     sso_users (user_uuid) { | |||
|         user_uuid -> Text, | |||
|         identifier -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     emergency_access (uuid) { | |||
|         uuid -> Text, | |||
|         grantor_uuid -> Text, | |||
|         grantee_uuid -> Nullable<Text>, | |||
|         email -> Nullable<Text>, | |||
|         key_encrypted -> Nullable<Text>, | |||
|         atype -> Integer, | |||
|         status -> Integer, | |||
|         wait_time_days -> Integer, | |||
|         recovery_initiated_at -> Nullable<Timestamp>, | |||
|         last_notification_at -> Nullable<Timestamp>, | |||
|         updated_at -> Timestamp, | |||
|         created_at -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     groups (uuid) { | |||
|         uuid -> Text, | |||
|         organizations_uuid -> Text, | |||
|         name -> Text, | |||
|         access_all -> Bool, | |||
|         external_id -> Nullable<Text>, | |||
|         creation_date -> Timestamp, | |||
|         revision_date -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     groups_users (groups_uuid, users_organizations_uuid) { | |||
|         groups_uuid -> Text, | |||
|         users_organizations_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     collections_groups (collections_uuid, groups_uuid) { | |||
|         collections_uuid -> Text, | |||
|         groups_uuid -> Text, | |||
|         read_only -> Bool, | |||
|         hide_passwords -> Bool, | |||
|         manage -> Bool, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     auth_requests  (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Text, | |||
|         organization_uuid -> Nullable<Text>, | |||
|         request_device_identifier -> Text, | |||
|         device_type -> Integer, | |||
|         request_ip -> Text, | |||
|         response_device_id -> Nullable<Text>, | |||
|         access_code -> Text, | |||
|         public_key -> Text, | |||
|         enc_key -> Nullable<Text>, | |||
|         master_password_hash -> Nullable<Text>, | |||
|         approved -> Nullable<Bool>, | |||
|         creation_date -> Timestamp, | |||
|         response_date -> Nullable<Timestamp>, | |||
|         authentication_date -> Nullable<Timestamp>, | |||
|     } | |||
| } | |||
| 
 | |||
| joinable!(attachments -> ciphers (cipher_uuid)); | |||
| joinable!(ciphers -> organizations (organization_uuid)); | |||
| joinable!(ciphers -> users (user_uuid)); | |||
| joinable!(ciphers_collections -> ciphers (cipher_uuid)); | |||
| joinable!(ciphers_collections -> collections (collection_uuid)); | |||
| joinable!(collections -> organizations (org_uuid)); | |||
| joinable!(devices -> users (user_uuid)); | |||
| joinable!(folders -> users (user_uuid)); | |||
| joinable!(folders_ciphers -> ciphers (cipher_uuid)); | |||
| joinable!(folders_ciphers -> folders (folder_uuid)); | |||
| joinable!(org_policies -> organizations (org_uuid)); | |||
| joinable!(sends -> organizations (organization_uuid)); | |||
| joinable!(sends -> users (user_uuid)); | |||
| joinable!(twofactor -> users (user_uuid)); | |||
| joinable!(users_collections -> collections (collection_uuid)); | |||
| joinable!(users_collections -> users (user_uuid)); | |||
| joinable!(users_organizations -> organizations (org_uuid)); | |||
| joinable!(users_organizations -> users (user_uuid)); | |||
| joinable!(users_organizations -> ciphers (org_uuid)); | |||
| joinable!(organization_api_key -> organizations (org_uuid)); | |||
| joinable!(emergency_access -> users (grantor_uuid)); | |||
| joinable!(groups -> organizations (organizations_uuid)); | |||
| joinable!(groups_users -> users_organizations (users_organizations_uuid)); | |||
| joinable!(groups_users -> groups (groups_uuid)); | |||
| joinable!(collections_groups -> collections (collections_uuid)); | |||
| joinable!(collections_groups -> groups (groups_uuid)); | |||
| joinable!(event -> users_organizations (uuid)); | |||
| joinable!(auth_requests -> users (user_uuid)); | |||
| joinable!(sso_users -> users (user_uuid)); | |||
| 
 | |||
| allow_tables_to_appear_in_same_query!( | |||
|     attachments, | |||
|     ciphers, | |||
|     ciphers_collections, | |||
|     collections, | |||
|     devices, | |||
|     folders, | |||
|     folders_ciphers, | |||
|     invitations, | |||
|     org_policies, | |||
|     organizations, | |||
|     sends, | |||
|     sso_users, | |||
|     twofactor, | |||
|     users, | |||
|     users_collections, | |||
|     users_organizations, | |||
|     organization_api_key, | |||
|     emergency_access, | |||
|     groups, | |||
|     groups_users, | |||
|     collections_groups, | |||
|     event, | |||
|     auth_requests, | |||
| ); | |||
| @ -1,395 +0,0 @@ | |||
| table! { | |||
|     attachments (id) { | |||
|         id -> Text, | |||
|         cipher_uuid -> Text, | |||
|         file_name -> Text, | |||
|         file_size -> BigInt, | |||
|         akey -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     ciphers (uuid) { | |||
|         uuid -> Text, | |||
|         created_at -> Timestamp, | |||
|         updated_at -> Timestamp, | |||
|         user_uuid -> Nullable<Text>, | |||
|         organization_uuid -> Nullable<Text>, | |||
|         key -> Nullable<Text>, | |||
|         atype -> Integer, | |||
|         name -> Text, | |||
|         notes -> Nullable<Text>, | |||
|         fields -> Nullable<Text>, | |||
|         data -> Text, | |||
|         password_history -> Nullable<Text>, | |||
|         deleted_at -> Nullable<Timestamp>, | |||
|         reprompt -> Nullable<Integer>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     ciphers_collections (cipher_uuid, collection_uuid) { | |||
|         cipher_uuid -> Text, | |||
|         collection_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     collections (uuid) { | |||
|         uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         name -> Text, | |||
|         external_id -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     devices (uuid, user_uuid) { | |||
|         uuid -> Text, | |||
|         created_at -> Timestamp, | |||
|         updated_at -> Timestamp, | |||
|         user_uuid -> Text, | |||
|         name -> Text, | |||
|         atype -> Integer, | |||
|         push_uuid -> Nullable<Text>, | |||
|         push_token -> Nullable<Text>, | |||
|         refresh_token -> Text, | |||
|         twofactor_remember -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     event (uuid) { | |||
|         uuid -> Text, | |||
|         event_type -> Integer, | |||
|         user_uuid -> Nullable<Text>, | |||
|         org_uuid -> Nullable<Text>, | |||
|         cipher_uuid -> Nullable<Text>, | |||
|         collection_uuid -> Nullable<Text>, | |||
|         group_uuid -> Nullable<Text>, | |||
|         org_user_uuid -> Nullable<Text>, | |||
|         act_user_uuid -> Nullable<Text>, | |||
|         device_type -> Nullable<Integer>, | |||
|         ip_address -> Nullable<Text>, | |||
|         event_date -> Timestamp, | |||
|         policy_uuid -> Nullable<Text>, | |||
|         provider_uuid -> Nullable<Text>, | |||
|         provider_user_uuid -> Nullable<Text>, | |||
|         provider_org_uuid -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     favorites (user_uuid, cipher_uuid) { | |||
|         user_uuid -> Text, | |||
|         cipher_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     folders (uuid) { | |||
|         uuid -> Text, | |||
|         created_at -> Timestamp, | |||
|         updated_at -> Timestamp, | |||
|         user_uuid -> Text, | |||
|         name -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     folders_ciphers (cipher_uuid, folder_uuid) { | |||
|         cipher_uuid -> Text, | |||
|         folder_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     invitations (email) { | |||
|         email -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     org_policies (uuid) { | |||
|         uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         atype -> Integer, | |||
|         enabled -> Bool, | |||
|         data -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     organizations (uuid) { | |||
|         uuid -> Text, | |||
|         name -> Text, | |||
|         billing_email -> Text, | |||
|         private_key -> Nullable<Text>, | |||
|         public_key -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     sends (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Nullable<Text>, | |||
|         organization_uuid -> Nullable<Text>, | |||
|         name -> Text, | |||
|         notes -> Nullable<Text>, | |||
|         atype -> Integer, | |||
|         data -> Text, | |||
|         akey -> Text, | |||
|         password_hash -> Nullable<Binary>, | |||
|         password_salt -> Nullable<Binary>, | |||
|         password_iter -> Nullable<Integer>, | |||
|         max_access_count -> Nullable<Integer>, | |||
|         access_count -> Integer, | |||
|         creation_date -> Timestamp, | |||
|         revision_date -> Timestamp, | |||
|         expiration_date -> Nullable<Timestamp>, | |||
|         deletion_date -> Timestamp, | |||
|         disabled -> Bool, | |||
|         hide_email -> Nullable<Bool>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     twofactor (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Text, | |||
|         atype -> Integer, | |||
|         enabled -> Bool, | |||
|         data -> Text, | |||
|         last_used -> BigInt, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     twofactor_incomplete (user_uuid, device_uuid) { | |||
|         user_uuid -> Text, | |||
|         device_uuid -> Text, | |||
|         device_name -> Text, | |||
|         device_type -> Integer, | |||
|         login_time -> Timestamp, | |||
|         ip_address -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     twofactor_duo_ctx (state) { | |||
|         state -> Text, | |||
|         user_email -> Text, | |||
|         nonce -> Text, | |||
|         exp -> BigInt, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     users (uuid) { | |||
|         uuid -> Text, | |||
|         enabled -> Bool, | |||
|         created_at -> Timestamp, | |||
|         updated_at -> Timestamp, | |||
|         verified_at -> Nullable<Timestamp>, | |||
|         last_verifying_at -> Nullable<Timestamp>, | |||
|         login_verify_count -> Integer, | |||
|         email -> Text, | |||
|         email_new -> Nullable<Text>, | |||
|         email_new_token -> Nullable<Text>, | |||
|         name -> Text, | |||
|         password_hash -> Binary, | |||
|         salt -> Binary, | |||
|         password_iterations -> Integer, | |||
|         password_hint -> Nullable<Text>, | |||
|         akey -> Text, | |||
|         private_key -> Nullable<Text>, | |||
|         public_key -> Nullable<Text>, | |||
|         totp_secret -> Nullable<Text>, | |||
|         totp_recover -> Nullable<Text>, | |||
|         security_stamp -> Text, | |||
|         stamp_exception -> Nullable<Text>, | |||
|         equivalent_domains -> Text, | |||
|         excluded_globals -> Text, | |||
|         client_kdf_type -> Integer, | |||
|         client_kdf_iter -> Integer, | |||
|         client_kdf_memory -> Nullable<Integer>, | |||
|         client_kdf_parallelism -> Nullable<Integer>, | |||
|         api_key -> Nullable<Text>, | |||
|         avatar_color -> Nullable<Text>, | |||
|         external_id -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     users_collections (user_uuid, collection_uuid) { | |||
|         user_uuid -> Text, | |||
|         collection_uuid -> Text, | |||
|         read_only -> Bool, | |||
|         hide_passwords -> Bool, | |||
|         manage -> Bool, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     users_organizations (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         invited_by_email -> Nullable<Text>, | |||
|         access_all -> Bool, | |||
|         akey -> Text, | |||
|         status -> Integer, | |||
|         atype -> Integer, | |||
|         reset_password_key -> Nullable<Text>, | |||
|         external_id -> Nullable<Text>, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     organization_api_key (uuid, org_uuid) { | |||
|         uuid -> Text, | |||
|         org_uuid -> Text, | |||
|         atype -> Integer, | |||
|         api_key -> Text, | |||
|         revision_date -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     sso_nonce (state) { | |||
|         state -> Text, | |||
|         nonce -> Text, | |||
|         verifier -> Nullable<Text>, | |||
|         redirect_uri -> Text, | |||
|         created_at -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     sso_users (user_uuid) { | |||
|         user_uuid -> Text, | |||
|         identifier -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     emergency_access (uuid) { | |||
|         uuid -> Text, | |||
|         grantor_uuid -> Text, | |||
|         grantee_uuid -> Nullable<Text>, | |||
|         email -> Nullable<Text>, | |||
|         key_encrypted -> Nullable<Text>, | |||
|         atype -> Integer, | |||
|         status -> Integer, | |||
|         wait_time_days -> Integer, | |||
|         recovery_initiated_at -> Nullable<Timestamp>, | |||
|         last_notification_at -> Nullable<Timestamp>, | |||
|         updated_at -> Timestamp, | |||
|         created_at -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     groups (uuid) { | |||
|         uuid -> Text, | |||
|         organizations_uuid -> Text, | |||
|         name -> Text, | |||
|         access_all -> Bool, | |||
|         external_id -> Nullable<Text>, | |||
|         creation_date -> Timestamp, | |||
|         revision_date -> Timestamp, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     groups_users (groups_uuid, users_organizations_uuid) { | |||
|         groups_uuid -> Text, | |||
|         users_organizations_uuid -> Text, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     collections_groups (collections_uuid, groups_uuid) { | |||
|         collections_uuid -> Text, | |||
|         groups_uuid -> Text, | |||
|         read_only -> Bool, | |||
|         hide_passwords -> Bool, | |||
|         manage -> Bool, | |||
|     } | |||
| } | |||
| 
 | |||
| table! { | |||
|     auth_requests  (uuid) { | |||
|         uuid -> Text, | |||
|         user_uuid -> Text, | |||
|         organization_uuid -> Nullable<Text>, | |||
|         request_device_identifier -> Text, | |||
|         device_type -> Integer, | |||
|         request_ip -> Text, | |||
|         response_device_id -> Nullable<Text>, | |||
|         access_code -> Text, | |||
|         public_key -> Text, | |||
|         enc_key -> Nullable<Text>, | |||
|         master_password_hash -> Nullable<Text>, | |||
|         approved -> Nullable<Bool>, | |||
|         creation_date -> Timestamp, | |||
|         response_date -> Nullable<Timestamp>, | |||
|         authentication_date -> Nullable<Timestamp>, | |||
|     } | |||
| } | |||
| 
 | |||
| joinable!(attachments -> ciphers (cipher_uuid)); | |||
| joinable!(ciphers -> organizations (organization_uuid)); | |||
| joinable!(ciphers -> users (user_uuid)); | |||
| joinable!(ciphers_collections -> ciphers (cipher_uuid)); | |||
| joinable!(ciphers_collections -> collections (collection_uuid)); | |||
| joinable!(collections -> organizations (org_uuid)); | |||
| joinable!(devices -> users (user_uuid)); | |||
| joinable!(folders -> users (user_uuid)); | |||
| joinable!(folders_ciphers -> ciphers (cipher_uuid)); | |||
| joinable!(folders_ciphers -> folders (folder_uuid)); | |||
| joinable!(org_policies -> organizations (org_uuid)); | |||
| joinable!(sends -> organizations (organization_uuid)); | |||
| joinable!(sends -> users (user_uuid)); | |||
| joinable!(twofactor -> users (user_uuid)); | |||
| joinable!(users_collections -> collections (collection_uuid)); | |||
| joinable!(users_collections -> users (user_uuid)); | |||
| joinable!(users_organizations -> organizations (org_uuid)); | |||
| joinable!(users_organizations -> users (user_uuid)); | |||
| joinable!(users_organizations -> ciphers (org_uuid)); | |||
| joinable!(organization_api_key -> organizations (org_uuid)); | |||
| joinable!(emergency_access -> users (grantor_uuid)); | |||
| joinable!(groups -> organizations (organizations_uuid)); | |||
| joinable!(groups_users -> users_organizations (users_organizations_uuid)); | |||
| joinable!(groups_users -> groups (groups_uuid)); | |||
| joinable!(collections_groups -> collections (collections_uuid)); | |||
| joinable!(collections_groups -> groups (groups_uuid)); | |||
| joinable!(event -> users_organizations (uuid)); | |||
| joinable!(auth_requests -> users (user_uuid)); | |||
| joinable!(sso_users -> users (user_uuid)); | |||
| 
 | |||
| allow_tables_to_appear_in_same_query!( | |||
|     attachments, | |||
|     ciphers, | |||
|     ciphers_collections, | |||
|     collections, | |||
|     devices, | |||
|     folders, | |||
|     folders_ciphers, | |||
|     invitations, | |||
|     org_policies, | |||
|     organizations, | |||
|     sends, | |||
|     sso_users, | |||
|     twofactor, | |||
|     users, | |||
|     users_collections, | |||
|     users_organizations, | |||
|     organization_api_key, | |||
|     emergency_access, | |||
|     groups, | |||
|     groups_users, | |||
|     collections_groups, | |||
|     event, | |||
|     auth_requests, | |||
| ); | |||
					Loading…
					
					
				
		Reference in new issue