Skip to content

Commit

Permalink
fix(application-system): Payment migration for definition to text fro…
Browse files Browse the repository at this point in the history
…m string (#16527)

* migration for defintion to text from string

* add a validation check on down

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and svanaeinars committed Oct 23, 2024
1 parent d7cf686 commit cda56ad
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict'

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.changeColumn('payment', 'definition', {
type: Sequelize.TEXT,
allowNull: true,
})
},

down: async (queryInterface, Sequelize) => {
// Check for records that might be truncated
const records = await queryInterface.sequelize.query(
`SELECT id FROM payment WHERE LENGTH(CAST(definition AS TEXT)) > 255`,
)
if (records[0].length > 0) {
throw new Error(
'Cannot safely rollback: Some records exceed STRING length limit',
)
}

await queryInterface.changeColumn('payment', 'definition', {
type: Sequelize.STRING,
allowNull: true,
})
},
}

0 comments on commit cda56ad

Please sign in to comment.