added migration for Certificate column types

This commit is contained in:
bill bittner 2017-11-07 15:21:42 -08:00
parent dce1c32288
commit e49942344a
2 changed files with 79 additions and 5 deletions

View file

@ -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]);
},
};

View file

@ -25,7 +25,7 @@ function sortResult (result, longId) {
return shortId; 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( const Claim = sequelize.define(
'Claim', 'Claim',
{ {
@ -34,7 +34,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
default: null, default: null,
}, },
amount: { amount: {
type : STRING, type : DOUBLE,
default: null, default: null,
}, },
claimId: { claimId: {
@ -54,7 +54,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
default: null, default: null,
}, },
effectiveAmount: { effectiveAmount: {
type : STRING, type : DOUBLE,
default: null, default: null,
}, },
hasSignature: { hasSignature: {
@ -62,7 +62,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
default: null, default: null,
}, },
height: { height: {
type : STRING, type : INTEGER,
default: null, default: null,
}, },
hex: { hex: {
@ -82,7 +82,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
default: null, default: null,
}, },
validAtHeight: { validAtHeight: {
type : STRING, type : INTEGER,
default: null, default: null,
}, },
outpoint: { outpoint: {