basic seed files and restructuring
This commit is contained in:
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'config': path.resolve('./app/config', 'config.js'),
|
'config': path.resolve('./app/config', 'migrations.config.js'),
|
||||||
'models-path': path.resolve('./app', 'models'),
|
'models-path': path.resolve('./', 'models'),
|
||||||
'seeders-path': path.resolve('./app', './seeders'),
|
'seeders-path': path.resolve('./', 'seeders'),
|
||||||
'migrations-path': path.resolve('./app', './migrations')
|
'migrations-path': path.resolve('./', 'migrations')
|
||||||
}
|
}
|
||||||
+10
-10
@@ -1,14 +1,14 @@
|
|||||||
const Sequelize = require('sequelize'),
|
const Sequelize = require('sequelize'),
|
||||||
DonorModel = require('../models/donor.model.js'),
|
DonorModel = require('../../models/donor.model.js'),
|
||||||
GrantModel = require('../models/grant.model.js'),
|
GrantModel = require('../../models/grant.model.js'),
|
||||||
CauseModel = require('../models/cause.model.js'),
|
CauseModel = require('../../models/cause.model.js'),
|
||||||
RegionModel = require('../models/region.model.js'),
|
RegionModel = require('../../models/region.model.js'),
|
||||||
OrganizationModel = require('../models/organization.model.js'),
|
OrganizationModel = require('../../models/organization.model.js'),
|
||||||
UserModel = require('../models/user.model.js'),
|
UserModel = require('../../models/user.model.js'),
|
||||||
PaymentPlanModel = require('../models/paymentplan.model'),
|
PaymentPlanModel = require('../../models/paymentplan.model'),
|
||||||
ChargeModel = require('../models/charge.model'),
|
ChargeModel = require('../../models/charge.model'),
|
||||||
OrgBankModel = require('../models/orgBank.model'),
|
OrgBankModel = require('../../models/orgBank.model'),
|
||||||
GrantsOrganizationsModel = require('../models/grantsOrganizations.model'),
|
GrantsOrganizationsModel = require('../../models/grantsOrganizations.model'),
|
||||||
associate = require('./associate');
|
associate = require('./associate');
|
||||||
|
|
||||||
const connection_uri = process.env.JAWSDB_MARIA_URL;
|
const connection_uri = process.env.JAWSDB_MARIA_URL;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module.exports = {
|
|||||||
development: {
|
development: {
|
||||||
username: 'root',
|
username: 'root',
|
||||||
password: 'water',
|
password: 'water',
|
||||||
database: 'ucharify',
|
database: 'base',
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
dialect: 'mysql'
|
dialect: 'mysql'
|
||||||
},
|
},
|
||||||
@@ -54,11 +54,8 @@ exports.create = async (req, res, next) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// cause or region not found
|
// cause or region not found
|
||||||
if (!causes.length) {
|
if (!causes.length || !regions.length) {
|
||||||
await Cause.create({ name: primary_cause }, { transaction });
|
throw errorMaker(400, `No valid cause or region`);
|
||||||
}
|
|
||||||
if (!regions.length) {
|
|
||||||
await Region.create({ name: primary_region }, { transaction });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const saltRounds = await bcrypt.genSaltSync(10);
|
const saltRounds = await bcrypt.genSaltSync(10);
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.changeColumn('organizations', 'rating', {
|
|
||||||
type: Sequelize.INTEGER,
|
|
||||||
defaultValue: 5,
|
|
||||||
allowNull: false
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.changeColumn('organizations', 'rating', {
|
|
||||||
type: Sequelize.INTEGER,
|
|
||||||
defaultValue: 0,
|
|
||||||
allowNull: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.createTable('users', {
|
|
||||||
id: {
|
|
||||||
allowNull: false,
|
|
||||||
autoIncrement: true,
|
|
||||||
primaryKey: true,
|
|
||||||
type: Sequelize.INTEGER
|
|
||||||
},
|
|
||||||
first_name: Sequelize.STRING,
|
|
||||||
last_name: Sequelize.STRING,
|
|
||||||
email: {
|
|
||||||
type: Sequelize.STRING,
|
|
||||||
validate: {
|
|
||||||
isEmail: true
|
|
||||||
},
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
createdAt: {
|
|
||||||
allowNull: false,
|
|
||||||
type: Sequelize.DATE,
|
|
||||||
defaultValue: new Date()
|
|
||||||
},
|
|
||||||
updatedAt: {
|
|
||||||
allowNull: false,
|
|
||||||
type: Sequelize.DATE,
|
|
||||||
defaultValue: new Date()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('donors', 'stripe_id', {
|
|
||||||
type: Sequelize.UUID,
|
|
||||||
defaultValue: null
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.createTable('charges', {
|
|
||||||
id: {
|
|
||||||
allowNull: false,
|
|
||||||
autoIncrement: true,
|
|
||||||
primaryKey: true,
|
|
||||||
type: Sequelize.INTEGER
|
|
||||||
},
|
|
||||||
amount: {
|
|
||||||
allowNull: false,
|
|
||||||
type: Sequelize.INTEGER
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
type: Sequelize.STRING
|
|
||||||
},
|
|
||||||
createdAt: {
|
|
||||||
allowNull: false,
|
|
||||||
type: Sequelize.DATE,
|
|
||||||
defaultValue: new Date()
|
|
||||||
},
|
|
||||||
updatedAt: {
|
|
||||||
allowNull: false,
|
|
||||||
type: Sequelize.DATE,
|
|
||||||
defaultValue: new Date()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.dropTable('charges');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('payment_plans', 'sub_item_id', {
|
|
||||||
type: Sequelize.UUID,
|
|
||||||
unique: true
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
'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" }
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,14 +1,24 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
const bcrypt = require('bcrypt-nodejs');
|
||||||
|
|
||||||
// DOESNT WORK AS NEED TO HASH PASSWORD TO DB
|
// DOESNT WORK AS NEED TO HASH PASSWORD TO DB
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: async (queryInterface, Sequelize) => {
|
||||||
|
|
||||||
|
var hash = bcrypt.hashSync('test', null);
|
||||||
|
|
||||||
return queryInterface.bulkInsert('donors', [
|
return queryInterface.bulkInsert('donors', [
|
||||||
{
|
{
|
||||||
first_name: 'Arjun',
|
first_name: 'Arjun',
|
||||||
email: 'patel.arjun50@gmail.com',
|
|
||||||
password: 'test',
|
|
||||||
last_name: 'Patel',
|
last_name: 'Patel',
|
||||||
|
email: 'patelarjun50@gmail.com',
|
||||||
|
password: hash, //hashed password
|
||||||
|
age: 20,
|
||||||
|
phone: 9499230445,
|
||||||
|
address: '14872 Waverly Lane',
|
||||||
|
city: 'Irvine',
|
||||||
|
state: 'CA',
|
||||||
|
country: 'US',
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date()
|
updated_at: new Date()
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,11 @@ module.exports = {
|
|||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.bulkInsert('causes', [
|
return queryInterface.bulkInsert('causes', [
|
||||||
{
|
{
|
||||||
id: 1,
|
|
||||||
name: 'Animal Care',
|
name: 'Animal Care',
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date()
|
updated_at: new Date()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
|
||||||
name: 'Water',
|
name: 'Water',
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date()
|
updated_at: new Date()
|
||||||
@@ -19,6 +17,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.bulkDelete('causes');
|
return queryInterface.bulkDelete('causes', [{ name: 'Water' }, { name: 'Animal Care' }]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -4,7 +4,6 @@ module.exports = {
|
|||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.bulkInsert('regions', [
|
return queryInterface.bulkInsert('regions', [
|
||||||
{
|
{
|
||||||
id: 1,
|
|
||||||
name: 'North India',
|
name: 'North India',
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date()
|
updated_at: new Date()
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.bulkInsert('organizations', [
|
||||||
|
{
|
||||||
|
name: 'Gopala Goshala',
|
||||||
|
email: 'kcp1982@yahoo.com',
|
||||||
|
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" }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user