Skip to content

Commit

Permalink
more seed fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgul committed May 20, 2024
1 parent fdfe9ab commit d0b5d78
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/server/knex/seeds/admin_role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ exports.seed = async(knex) =>
/* eslint-disable no-await-in-loop */

// Do a `mapSeries` over admins, and add them and their `account_role entry`, if needed.
for(const account of admins)
for(const acc of admins)
{
const exists = (await knex('account').select()
.where({ email: account.email })).length > 0;
if(!exists)
let account = await knex('account').select()
.where({ email: acc.email })
.first();

if(!account)
{
await knex('account').insert(account);
await knex('account').insert(acc);
account = acc;
}

const linkExists = (await knex('account_role').select()
Expand All @@ -61,13 +64,16 @@ exports.seed = async(knex) =>
}

// Do a `mapSeries` over mods, and add them and their `account_role entry`, if needed.
for(const account of mods)
for(const acc of mods)
{
const exists = (await knex('account').select()
.where({ email: account.email })).length > 0;
if(!exists)
let account = await knex('account').select()
.where({ email: acc.email })
.first();

if(!account)
{
await knex('account').insert(account);
await knex('account').insert(acc);
account = acc;
}

const linkExists = (await knex('account_role').select()
Expand Down

0 comments on commit d0b5d78

Please sign in to comment.