integration with migrations/seeds/etc
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
// DOESNT WORK AS NEED TO HASH PASSWORD TO DB
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('donors', [
|
||||
{
|
||||
first_name: 'Arjun',
|
||||
email: '[email protected]',
|
||||
password: 'test',
|
||||
last_name: 'Patel',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('donors', {
|
||||
email: '[email protected]'
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('causes', [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Animal Care',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Water',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('causes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('regions', [
|
||||
{
|
||||
id: 1,
|
||||
name: 'North India',
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
}
|
||||
]);
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkDelete('regions', { name: 'North India' });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.bulkInsert('organizations', [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Gopala Goshala',
|
||||
short_description: 'We are committed to animal shelter!',
|
||||
primary_cause: 'Animal Care',
|
||||
primary_region: 'North India',
|
||||
rating: 9.2,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Water Organization India',
|
||||
short_description: 'We love water! So should you!',
|
||||
primary_cause: 'Water',
|
||||
primary_region: 'North India',
|
||||
rating: 8,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date()
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Pete's Animals",
|
||||
short_description: 'Help us protect animals!',
|
||||
primary_cause: 'Animal Care',
|
||||
primary_region: 'North India',
|
||||
rating: 7.5,
|
||||
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" }
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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