Skip to content

Commit

Permalink
Add option to skip creating an env for account seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
nalanj committed Jan 3, 2025
1 parent 531357b commit 09d638d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/shared/lib/seeders/account.seeder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import accountService from '../services/account.service.js';
import type { DBTeam } from '@nangohq/types';

export async function createAccount(): Promise<DBTeam> {
const acc = await accountService.getOrCreateAccount(uuid());
const acc = await accountService.getOrCreateAccount(uuid(), false);
if (!acc) {
throw new Error('failed_to_create_account');
}
Expand Down
7 changes: 5 additions & 2 deletions packages/shared/lib/services/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AccountService {
return account[0].uuid;
}

async getOrCreateAccount(name: string): Promise<DBTeam> {
async getOrCreateAccount(name: string, createDefaultEnvironments = true): Promise<DBTeam> {
const account: DBTeam[] = await db.knex.select('id').from<DBTeam>(`_nango_accounts`).where({ name });

if (account == null || account.length == 0 || !account[0]) {
Expand All @@ -70,7 +70,10 @@ class AccountService {
if (!newAccount || newAccount.length == 0 || !newAccount[0]) {
throw new Error('Failed to create account');
}
await environmentService.createDefaultEnvironments(newAccount[0]['id']);

if (createDefaultEnvironments) {
await environmentService.createDefaultEnvironments(newAccount[0]['id']);
}

return newAccount[0];
}
Expand Down

0 comments on commit 09d638d

Please sign in to comment.