adding integration with payment sources table and within stripe controller

This commit is contained in:
Arjun Patel
2019-05-11 03:27:30 -07:00
parent f865781c07
commit 3c55717dda
6 changed files with 187 additions and 7 deletions
@@ -0,0 +1,37 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.createTable('payment_sources', {
id: {
allowNull: false,
primaryKey: true,
type: Sequelize.UUID
},
token: {
type: Sequelize.STRING
},
provider: {
type: Sequelize.STRING
},
donor_id: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: 'donors',
key: 'id'
}
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable('PaymentSources');
}
};
@@ -0,0 +1,39 @@
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
/*
Add altering commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
return queryInterface
.addColumn('grants', 'payment_source_id', Sequelize.UUID)
.then(() =>
queryInterface.addConstraint('grants', ['payment_source_id'], {
type: 'foreign key',
name: 'grants_paymentsources_fk',
references: {
//Required field
table: 'payment_sources',
field: 'id'
},
onDelete: 'cascade',
onUpdate: 'cascade'
})
);
},
down: (queryInterface, Sequelize) => {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.
Example:
return queryInterface.dropTable('users');
*/
return queryInterface.removeColumn('grants', 'payment_source_id');
}
};