Skip to content

Commit 837e227

Browse files
committed
fix: gracefully handle lack of permission for DB/table creation
1 parent 7be8466 commit 837e227

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/storage/sqlx/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,14 @@ impl SqlxBackend {
187187

188188
match db_name {
189189
DatabaseName::MySql(database_name) => {
190-
let _ = sqlx::query(&format!("CREATE DATABASE IF NOT EXISTS `{database_name}`")).execute(&pool).await?;
191-
let _ = sqlx::query(&format!("CREATE TABLE IF NOT EXISTS `{database_name}`.`{table_name}` (vault_key varbinary(3072), vault_value mediumblob, PRIMARY KEY (vault_key))")).execute(&pool).await?;
190+
let ret = sqlx::query(&format!("CREATE DATABASE IF NOT EXISTS `{database_name}`")).execute(&pool).await;
191+
if ret.is_err() {
192+
log::warn!("sqlx create database error: {:?}", ret.err());
193+
}
194+
let ret = sqlx::query(&format!("CREATE TABLE IF NOT EXISTS `{database_name}`.`{table_name}` (vault_key varbinary(3072), vault_value mediumblob, PRIMARY KEY (vault_key))")).execute(&pool).await;
195+
if ret.is_err() {
196+
log::warn!("sqlx create table error: {:?}", ret.err());
197+
}
192198
}
193199
_ => {
194200
return Err(RvError::ErrDatabaseTypeInvalid);

0 commit comments

Comments
 (0)