Reputation: 3867
I am using sequelize
to perform migrations on my database. I would like to change the collation of a column in an existing table via a migration file, but I don't find where should I put this information. I've searched in the documentation to no avail, and neither does my intellisense give me any info when trying to write the code in typescript.
export async function up(queryInterface: QueryInterface, Sequelize: Sequelize) {
await queryInterface.changeColumn('PageHits', 'SessionId', {
/** I want to change this columns collation **/
});
}
Under what property should I put the collation information into?
Upvotes: 0
Views: 527
Reputation: 27609
Pass the collate value into the changeColumn()
options. You should list the "before" and "after" as the same column name.
export async function up(queryInterface: QueryInterface, Sequelize: Sequelize) {
const collate = 'your collation';
await queryInterface.changeColumn(
'PageHits', // table name
'SessionId', // before column name
'SessionId', // after column name
{
collate, // collation
},
});
}
Upvotes: 1