Skip to content

Commit c4a2d9b

Browse files
夏一飞夏一飞
authored andcommitted
refactor: ensure table and column checks in user functions
1 parent 7909b1b commit c4a2d9b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/db/users.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ async function ensureDeletedColumnExists() {
134134
}
135135

136136
export async function deleteUser(userId: string) {
137+
await ensureUserTableExists();
137138
await ensureDeletedColumnExists();
138139

139140
const updateResult = await query(
@@ -163,6 +164,7 @@ export async function getUsers({
163164
search = null,
164165
}: GetUsersOptions = {}) {
165166
await ensureUserTableExists();
167+
await ensureDeletedColumnExists();
166168

167169
const offset = (page - 1) * pageSize;
168170

@@ -219,6 +221,9 @@ export async function getUsers({
219221
}
220222

221223
export async function getAllUsers(includeDeleted: boolean = false) {
224+
await ensureUserTableExists();
225+
await ensureDeletedColumnExists();
226+
222227
const whereClause = includeDeleted
223228
? ""
224229
: "WHERE (deleted = FALSE OR deleted IS NULL)";

0 commit comments

Comments
 (0)