basic seed files and restructuring
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
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', [
|
||||
{
|
||||
first_name: 'Arjun',
|
||||
last_name: 'Patel',
|
||||
email: '[email protected]',
|
||||
password: hash, //hashed password
|
||||
age: 20,
|
||||
phone: 9499230445,
|
||||
address: '14872 Waverly Lane',
|
||||
city: 'Irvine',
|
||||
state: 'CA',
|
||||
country: 'US',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('donors', {
|
||||
email: '[email protected]'
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('causes', [
|
||||
{
|
||||
name: 'Animal Care',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
},
|
||||
{
|
||||
name: 'Water',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('causes', [{ name: 'Water' }, { name: 'Animal Care' }]);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('regions', [
|
||||
{
|
||||
name: 'North India',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('regions', { name: 'North India' });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('organizations', [
|
||||
{
|
||||
name: 'Gopala Goshala',
|
||||
email: '[email protected]',
|
||||
password: hashedPass, //hashed password
|
||||
short_description:
|
||||
'We are focused on bringing lawful animal treatment in North India. Check out our many projects such as city water fountains for animals',
|
||||
primary_cause: 'Animal',
|
||||
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
|
||||
},
|
||||
{
|
||||
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
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('organizations', {
|
||||
[Sequelize.Op.or]: [
|
||||
{ name: 'Gopala Goshala' },
|
||||
{ name: 'Water Organization India' },
|
||||
{ name: "Pete's Animals" }
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
'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='[email protected]'))`,
|
||||
{
|
||||
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, {});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user