Skip to content

Commit 6475b3a

Browse files
authored
Fix SQL export (#22)
1 parent 9863050 commit 6475b3a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/export-sql/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,16 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
2828
});
2929

3030
const categoryIds = new Map();
31-
for (const [key, spec] of getSpecs('categories')) {
31+
for (const [key] of getSpecs('categories')) {
3232
const { lastID } = await db.run(
3333
'INSERT INTO categories (name) VALUES (?)',
3434
key,
3535
);
3636
categoryIds.set(key, lastID);
3737
}
3838

39-
const companyIds = new Map();
4039
for (const [key, spec] of getSpecs('organizations')) {
41-
const { lastID } = await db.run(
40+
await db.run(
4241
'INSERT INTO companies (id, name, description, privacy_url, website_url, country, privacy_contact, notes, ghostery_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
4342
key,
4443
spec.field('name').requiredStringValue(),
@@ -50,7 +49,6 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
5049
spec.field('notes').optionalStringValue(),
5150
spec.field('ghostery_id').optionalStringValue() || '',
5251
);
53-
companyIds.set(key, lastID);
5452
}
5553

5654
for (const [key, spec] of getSpecs('patterns')) {
@@ -60,7 +58,7 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
6058
spec.field('name').requiredStringValue(),
6159
categoryIds.get(spec.field('category').requiredStringValue()),
6260
spec.field('website_url').optionalStringValue(),
63-
companyIds.get(spec.field('organization').optionalStringValue()) || null,
61+
spec.field('organization').optionalStringValue() || null,
6462
spec.field('notes').optionalStringValue(),
6563
spec.field('alias').optionalStringValue(),
6664
spec.field('ghostery_id').optionalStringValue() || '',
@@ -80,6 +78,8 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
8078
}
8179
}
8280

81+
await db.run('DROP TABLE migrations');
82+
8383
console.log(
8484
'Exported categories:',
8585
(await db.get('SELECT count(*) as count FROM categories')).count,

0 commit comments

Comments
 (0)