fix: Add username uniqueness check to admin user seeding

This commit is contained in:
Ayman
2026-07-08 07:17:32 +01:00
parent 0a2641db84
commit 7fbc2ea737
2 changed files with 23 additions and 5 deletions
+10
View File
@@ -78,6 +78,16 @@ exports.seed = async (knex) => {
const userData = buildUserData();
if (userData.username) {
const existingUsernameUser = await knex('user_account')
.where('username', userData.username)
.first();
if (existingUsernameUser) {
throw new Error(`User with DEFAULT_ADMIN_USERNAME "${userData.username}" already exists.`);
}
}
let userId;
try {
[{ id: userId }] = await knex('user_account').insert(