cleanup and working seed data

This commit is contained in:
Arjun Patel
2019-03-13 23:53:07 -07:00
parent acf6421251
commit 05a1003be2
10 changed files with 119 additions and 143 deletions
+1 -2
View File
@@ -4,7 +4,6 @@ const bcrypt = require('bcrypt-nodejs');
// DOESNT WORK AS NEED TO HASH PASSWORD TO DB
module.exports = {
up: async (queryInterface, Sequelize) => {
var hash = bcrypt.hashSync('test', null);
return queryInterface.bulkInsert('donors', [
@@ -27,7 +26,7 @@ module.exports = {
down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('donors', {
email: 'patel.arjun50@gmail.com'
email: 'patelarjun50@gmail.com'
});
}
};
+77 -48
View File
@@ -1,7 +1,10 @@
'use strict';
const bcrypt = require('bcrypt-nodejs');
module.exports = {
up: (queryInterface, Sequelize) => {
up: async (queryInterface, Sequelize) => {
var hashedPass = await bcrypt.hashSync('test', null);
return queryInterface.bulkInsert('organizations', [
{
name: 'Gopala Goshala',
@@ -18,7 +21,7 @@ module.exports = {
zip: '92604',
primary_cause: 'Animal',
primary_region: 'North India',
primary_region: 'South Asia',
ein: '63-6088665',
estimate_asset_value: 200000,
@@ -26,56 +29,82 @@ module.exports = {
isNonprofit: true,
primary_contact_phone,
primary_contact_first_name,
primary_contact_last_name
},
{
name,
email,
password: hashedPass, //hashed password
short_description,
primary_cause,
primary_region,
ein,
primary_contact_first_name,
primary_contact_last_name,
phone,
country,
address,
city,
zip,
estimate_assets,
estimate_year_operating_cost
},
{
name,
email,
password: hashedPass, //hashed password
short_description,
primary_cause,
primary_region,
ein,
primary_contact_first_name,
primary_contact_last_name,
phone,
country,
address,
city,
zip,
estimate_assets,
estimate_year_operating_cost
primary_contact_phone: '9493873423',
primary_contact_first_name: 'Kamlesh',
primary_contact_last_name: 'Patel',
created_at: new Date(),
updated_at: new Date()
}
// ,
// {
// name: 'The Pollination Project',
// short_description:
// 'Every day of the year, we give a grant to changemakers across the globe.',
// primary_contact_email: 'ajay@gmail.com',
// password: hashedPass,
// address: '2031 Carry Drive',
// city: 'San Francisco',
// country: 'USA',
// state: 'CA',
// zip: '92604',
// primary_cause: 'Animal',
// primary_region: 'South Asia',
// ein: '63-6088665',
// estimate_asset_value: 200000,
// estimate_yearly_operating_cost: 40000,
// isNonprofit: true,
// primary_contact_phone: '6254581254',
// primary_contact_first_name: 'Ajay',
// primary_contact_last_name: 'Datta',
// created_at: new Date(),
// updated_at: new Date()
// },
// {
// name: 'Cancer Global Perspective',
// short_description:
// 'Your tax-deductible donation funds lifesaving research, treatment and care — and would mean so much to someone fighting cancer. Please donate today.',
// primary_contact_email: 'cancersupport@gmail.com',
// password: hashedPass,
// address: '82912 Larry Page Drive',
// city: 'Holmes',
// country: 'USA',
// state: 'AZ',
// zip: '92604',
// primary_cause: 'Animal',
// primary_region: 'South Asia',
// ein: '63-6088665',
// estimate_asset_value: 200000,
// estimate_yearly_operating_cost: 40000,
// isNonprofit: true,
// primary_contact_phone: '6254581254',
// primary_contact_first_name: 'Leo',
// primary_contact_last_name: 'Rosen',
// created_at: new Date(),
// updated_at: new Date()
// }
]);
},
down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('organizations', {
[Sequelize.Op.or]: [
{ name: 'Gopala Goshala' },
{ name: 'Water Organization India' },
{ name: "Pete's Animals" }
]
});
return queryInterface.bulkDelete('organizations', [
{ primary_contact_email: 'kcp1982@yahoo.com' },
{ primary_contact_email: 'ajay@gmail.com' },
{ primary_contact_email: 'cancersupport@gmail.com' }
]);
}
};
-65
View File
@@ -1,65 +0,0 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
var sequelize = queryInterface.sequelize;
const causes = [1, 2],
regions = [1],
organizations = [1, 2, 3];
return Promise.all([
sequelize.query(
`INSERT INTO grants (id, name, amount, monthly, last_payment, num_causes, num_regions, created_at, updated_at, donor_id)
VALUES (1, 'Max Impact in the South', 1000, 1, :last_payment, 2, 1, :created_at, :updated_at, (select id from donors where email='patel.arjun50@gmail.com'))`,
{
replacements: {
last_payment: new Date(),
created_at: new Date(),
updated_at: new Date()
},
type: sequelize.QueryTypes.INSERT
}
),
sequelize.query(
`INSERT INTO grants_causes (grant_id, cause_id, created_at, updated_at)
VALUES ((select id from grants where id=1), select id from causes where name='Animal Care', :created_at, :updated_at),
((select id from grants where id=1), select id from causes where name='Water', :created_at, :updated_at)`,
{
replacements: {
created_at: new Date(),
updated_at: new Date()
},
type: sequelize.QueryTypes.INSERT
}
),
sequelize.query(
`INSERT INTO grants_regions (grant_id, cause_id, created_at, updated_at)
VALUES ((select id from grants where id=1), select id from causes where name='Animal Care', :created_at, :updated_at),
((select id from grants where id=1), select id from causes where name='Water', :created_at, :updated_at)`,
{
replacements: {
created_at: new Date(),
updated_at: new Date()
},
type: sequelize.QueryTypes.INSERT
}
),
sequelize.query(
`INSERT INTO grants_causes (grant_id, cause_id, created_at, updated_at)
VALUES ((select id from grants where id=1), select id from causes where name='Animal Care', :created_at, :updated_at),
((select id from grants where id=1), select id from causes where name='Water', :created_at, :updated_at)`,
{
replacements: {
created_at: new Date(),
updated_at: new Date()
},
type: sequelize.QueryTypes.INSERT
}
)
]);
},
down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('grants', null, {});
}
};