-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseeders.js
116 lines (107 loc) · 3.39 KB
/
seeders.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
'use strict';
import { getInfoFromprojectDb } from '../../services/projectDb';
const query = require('../../services/projectDb/projectQueries');
module.exports = {
up: async (queryInterface, Sequelize) => {
const ids = await getInfoFromprojectDb(query.queryCategoryAttributesIds);
if (ids) {
ids.map(entity => {
entity.createdAt = new Date();
entity.updatedAt = new Date();
return entity;
});
return queryInterface.bulkInsert('categoryAttributes', ids, {});
} else {
return queryInterface.bulkInsert(
'categoryAttributes',
[
{
categoryId: 24101,
attributeId: 2,
createdAt: new Date(),
updatedAt: new Date(),
},
{
categoryId: 24101,
attributeId: 3,
createdAt: new Date(),
updatedAt: new Date(),
},
{
categoryId: 24275,
attributeId: 3,
createdAt: new Date(),
updatedAt: new Date(),
},
],
{},
);
}
},
down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('categoryAttributes', null, {});
},
};
('use strict');
import { getInfoFromprojectDb } from '../../services/projectDb';
const query = require('../../services/projectDb/projectQueries');
module.exports = {
up: async (queryInterface, Sequelize) => {
const filters = await getInfoFromprojectDb(query.queryOnlyFilters);
if (filters) {
filters.map(filters => {
filters.createdAt = new Date();
filters.updatedAt = new Date();
return filters;
});
return queryInterface.bulkInsert('filtersType', filters, {
updateOnDuplicate: ['id', 'type', 'value'],
});
} else {
return queryInterface.bulkInsert(
'filtersType',
[
{ id: 1, type: 'decade', value: 'Decade' },
{ id: 2, type: 'book_genre', value: 'Genre' },
{ id: 5, type: 'platform', value: 'Platform' },
{ id: 6, type: 'release_year', value: 'Release Year' },
{
id: 7,
type: 'streaming_provider',
value: 'Streaming Provider',
},
{ id: 11, type: 'music_style', value: 'Style' },
{ id: 14, type: 'published_year', value: 'Year Published' },
{ id: 18, type: 'movie_genre', value: 'Genre' },
{ id: 19, type: 'tv_show_genre', value: 'Genre' },
{ id: 20, type: 'music_genre', value: 'Genre' },
],
{},
);
}
},
down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('filtersType', null, {});
},
};
('use strict');
import { getInfoFromprojectDb } from '../../services/projectDb';
const query = require('../../services/projectDb/projectQueries');
module.exports = {
up: async (queryInterface, Sequelize) => {
const categoryFilters = await getInfoFromprojectDb(query.queryFilterCategory);
if (categoryFilters) {
categoryFilters.map(() => {
categoryFilters.createdAt = new Date();
categoryFilters.updatedAt = new Date();
return categoryFilters;
});
return queryInterface.bulkInsert('filters', categoryFilters, {
updateOnDuplicate: ['id', 'categoryId', 'filterId'],
});
}
},
down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('filters', null, {});
},
};