diff --git a/migrations/ChangeCertificateColumnTypes.js b/migrations/ChangeCertificateColumnTypes.js new file mode 100644 index 00000000..95e62ebf --- /dev/null +++ b/migrations/ChangeCertificateColumnTypes.js @@ -0,0 +1,74 @@ +module.exports = { + up: (queryInterface, Sequelize) => { + // logic for transforming into the new state + const p1 = queryInterface.changeColumn( + 'Certificate', + 'amount', + { + type : Sequelize.DOUBLE, + allowNull: true, + } + ); + const p2 = queryInterface.changeColumn( + 'Certificate', + 'effectiveAmount', + { + type : Sequelize.DOUBLE, + allowNull: true, + } + ); + const p3 = queryInterface.changeColumn( + 'Certificate', + 'height', + { + type : Sequelize.INTEGER, + allowNull: true, + } + ); + const p4 = queryInterface.changeColumn( + 'Certificate', + 'validAtHeight', + { + type : Sequelize.INTEGER, + allowNull: true, + } + ); + return Promise.all([p1, p2, p3, p4]); + }, + down: (queryInterface, Sequelize) => { + // logic for reverting the changes + const p1 = queryInterface.changeColumn( + 'Certificate', + 'amount', + { + type : Sequelize.STRING, + allowNull: true, + } + ); + const p2 = queryInterface.changeColumn( + 'Certificate', + 'effectiveAmount', + { + type : Sequelize.STRING, + allowNull: true, + } + ); + const p3 = queryInterface.changeColumn( + 'Certificate', + 'height', + { + type : Sequelize.STRING, + allowNull: true, + } + ); + const p4 = queryInterface.changeColumn( + 'Certificate', + 'validAtHeight', + { + type : Sequelize.STRING, + allowNull: true, + } + ); + return Promise.all([p1, p2, p3, p4]); + }, +}; diff --git a/models/claim.js b/models/claim.js index 7145e9e0..992a7158 100644 --- a/models/claim.js +++ b/models/claim.js @@ -25,7 +25,7 @@ function sortResult (result, longId) { return shortId; } -module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, DOUBLE, Op }) => { +module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DOUBLE }) => { const Claim = sequelize.define( 'Claim', { @@ -34,7 +34,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D default: null, }, amount: { - type : STRING, + type : DOUBLE, default: null, }, claimId: { @@ -54,7 +54,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D default: null, }, effectiveAmount: { - type : STRING, + type : DOUBLE, default: null, }, hasSignature: { @@ -62,7 +62,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D default: null, }, height: { - type : STRING, + type : INTEGER, default: null, }, hex: { @@ -82,7 +82,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D default: null, }, validAtHeight: { - type : STRING, + type : INTEGER, default: null, }, outpoint: {