Here is the query
Please note it also happens on other tables. Pretty much all tables with custom queries don’t work, all with Simple work.
SELECT payments.billing_cycle AS key, SUM(payments.payment_amount + payments.enterprise_subsidy) as value
FROM payments
WHERE payments.billing_cycle is not null and payments.account_id is not null
GROUP BY key
ORDER BY key;
And full screenshot
And our model
'use strict'
module.exports = (sequelize, DataTypes) => {
var Model = sequelize.define(
'payments',
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
user_id: {
type: DataTypes.INTEGER
},
enterprise_id: {
type: DataTypes.INTEGER
},
payment_amount: {
type: DataTypes.FLOAT
},
status: {
type: DataTypes.ENUM(
'awaitingData',
'due',
'completed',
'failed',
'refunded'
)
},
stripe_data: {
type: DataTypes.JSON
},
subscription_id: {
type: DataTypes.INTEGER
},
total_cost: {
type: DataTypes.FLOAT
},
enterprise_subsidy: {
type: DataTypes.FLOAT
},
enterprise_max_subsidy: {
type: DataTypes.FLOAT
},
date_processed: {
type: DataTypes.DATE
},
received: {
type: DataTypes.BOOLEAN
},
amount_received: {
type: DataTypes.FLOAT
},
date_received: {
type: DataTypes.DATE
},
billing_cycle: {
type: DataTypes.STRING
},
created_at: {
type: DataTypes.DATE
},
updated_at: {
type: DataTypes.DATE
},
additional_fees: {
type: DataTypes.FLOAT
}
},
{
tableName: 'payments',
underscored: true
}
)
Model.associate = function(models) {
Model.belongsTo(models.subscriptions, {
foreignKey: 'subscription_id',
as: 'subscriptions'
})
}
return Model
}