I got an error when I was running a migration in sequelize, before I set typedatas text and i tried to change to json I got some error...
ERROR: column "value" cannot be cast automatically to type jsonb
This is the new code:
up: (queryInterface, Sequelize) => Promise.resolve()
.then(async () => {
await queryInterface.changeColumn('Action', 'value', {
type: Sequelize.JSONB,
allowNull: false,
defaultValue: {},
})
}),
and this is my migration code that I want to change:
up: (queryInterface, Sequelize) => queryInterface.createTable('Action', {
....
value: {
type: Sequelize.TEXT,
allowNull: false,
defaultValue: '',
},
....
}
What's wrong?
the accepted answer doesn't work for me.
I use this one and it works.
type: `${Sequelize.JSONB} using to_jsonb(col_name)`
simple solution... i change to
type: 'JSONB USING CAST ("value" as JSONB)'`
as in https://github.com/sequelize/sequelize/issues/2471
solved my problem ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With