@@ -28,17 +28,16 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
28
28
} ) ;
29
29
30
30
const categoryIds = new Map ( ) ;
31
- for ( const [ key , spec ] of getSpecs ( 'categories' ) ) {
31
+ for ( const [ key ] of getSpecs ( 'categories' ) ) {
32
32
const { lastID } = await db . run (
33
33
'INSERT INTO categories (name) VALUES (?)' ,
34
34
key ,
35
35
) ;
36
36
categoryIds . set ( key , lastID ) ;
37
37
}
38
38
39
- const companyIds = new Map ( ) ;
40
39
for ( const [ key , spec ] of getSpecs ( 'organizations' ) ) {
41
- const { lastID } = await db . run (
40
+ await db . run (
42
41
'INSERT INTO companies (id, name, description, privacy_url, website_url, country, privacy_contact, notes, ghostery_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' ,
43
42
key ,
44
43
spec . field ( 'name' ) . requiredStringValue ( ) ,
@@ -50,7 +49,6 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
50
49
spec . field ( 'notes' ) . optionalStringValue ( ) ,
51
50
spec . field ( 'ghostery_id' ) . optionalStringValue ( ) || '' ,
52
51
) ;
53
- companyIds . set ( key , lastID ) ;
54
52
}
55
53
56
54
for ( const [ key , spec ] of getSpecs ( 'patterns' ) ) {
@@ -60,7 +58,7 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
60
58
spec . field ( 'name' ) . requiredStringValue ( ) ,
61
59
categoryIds . get ( spec . field ( 'category' ) . requiredStringValue ( ) ) ,
62
60
spec . field ( 'website_url' ) . optionalStringValue ( ) ,
63
- companyIds . get ( spec . field ( 'organization' ) . optionalStringValue ( ) ) || null ,
61
+ spec . field ( 'organization' ) . optionalStringValue ( ) || null ,
64
62
spec . field ( 'notes' ) . optionalStringValue ( ) ,
65
63
spec . field ( 'alias' ) . optionalStringValue ( ) ,
66
64
spec . field ( 'ghostery_id' ) . optionalStringValue ( ) || '' ,
@@ -80,6 +78,8 @@ import { prepareDistFolder, BASE_PATH, getSpecs } from '../helpers.js';
80
78
}
81
79
}
82
80
81
+ await db . run ( 'DROP TABLE migrations' ) ;
82
+
83
83
console . log (
84
84
'Exported categories:' ,
85
85
( await db . get ( 'SELECT count(*) as count FROM categories' ) ) . count ,
0 commit comments