Skip to content

Commit

Permalink
修复初始化创建 mysql 表失败
Browse files Browse the repository at this point in the history
  • Loading branch information
veoco committed Jun 13, 2024
1 parent 6676f35 commit 64a2d2a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,18 @@ pub async fn init_table(state: &AppState) {
"#
}
};
let _ = state
.conn
.execute(Statement::from_string(db_backend, sql))
.await
.expect("database already exists");
let stmts = sql.split(";");
for stmt in stmts {
let stmt = stmt.trim();
if stmt.is_empty() {
continue;
}
let _ = state
.conn
.execute(Statement::from_string(db_backend, format!("{};", stmt)))
.await
.expect("database already exists");
}
}

pub async fn init_admin(state: &AppState, user_register: UserRegister) {
Expand Down

0 comments on commit 64a2d2a

Please sign in to comment.