fix seeds

This commit is contained in:
2025-12-27 01:25:56 +01:00
parent b68405aa46
commit 9a74e16f11
23 changed files with 405 additions and 564 deletions

View File

@@ -20,21 +20,23 @@ export class EnsureInitialData {
async execute(): Promise<void> {
// Ensure initial admin user exists
try {
await this.signupUseCase.execute({
email: 'admin@gridpilot.local',
password: 'admin123',
displayName: 'Admin',
});
const signupResult = await this.signupUseCase.execute({
email: 'admin@gridpilot.local',
password: 'admin123',
displayName: 'Admin',
});
if (signupResult.isOk()) {
this.logger.info('[Bootstrap] Initial admin user created');
} catch (error) {
if (error instanceof Error && error.message === 'An account with this email already exists') {
// User already exists, nothing to do
this.logger.info('[Bootstrap] Admin user already exists');
} else {
// Re-throw other errors
throw error;
}
} else if (signupResult.error?.code === 'EMAIL_ALREADY_EXISTS') {
this.logger.info('[Bootstrap] Admin user already exists');
} else {
const detailsMessage =
signupResult.error && typeof signupResult.error === 'object' && 'details' in signupResult.error
? (signupResult.error as { details?: { message?: string } }).details?.message
: undefined;
throw new Error(detailsMessage ?? 'Failed to ensure initial admin user');
}
// Ensure initial achievements exist