Normalized database. Updated seed files. Simplified seed upsert.

This commit is contained in:
2019-12-19 02:35:07 +01:00
parent 9b17add4e2
commit 31aee71edb
8 changed files with 578 additions and 530 deletions

View File

@@ -1755,9 +1755,4 @@ const countries = [
];
exports.seed = knex => knex('countries')
.then(async () => {
const duplicates = await knex('countries').select('*');
const duplicatesByAlpha2 = duplicates.reduce((acc, country) => ({ ...acc, [country.alpha2]: country }), {});
return upsert('countries', countries, duplicatesByAlpha2, 'alpha2', knex);
});
.then(async () => upsert('countries', countries, 'alpha2', knex));