Skip to content

Instantly share code, notes, and snippets.

@SidneyAllen
Created September 30, 2021 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SidneyAllen/8d812f8ba2eb43b28393d843ec635692 to your computer and use it in GitHub Desktop.
Save SidneyAllen/8d812f8ba2eb43b28393d843ec635692 to your computer and use it in GitHub Desktop.
'use strict';
const COLUMNS_TO_CHANGE = [
['table1',json_col],
[table2,json_col],
[table3,json_col],
[table4,json_col],
];
exports.up = async (Knex) => {
for (const tableColumnPair of COLUMNS_TO_CHANGE) {
await Knex.schema.table(tableColumnPair[0], (table) => {
table.jsonb(tableColumnPair[1] + '_jsonb');
});
}
};
exports.down = async (Knex) => {
for (const tableColumnPair of COLUMNS_TO_CHANGE) {
await Knex.schema.table(tableColumnPair[0], (table) => {
table.dropColumn(tableColumnPair[1] + '_jsonb');
});
}
};
exports.config = {
transaction: true
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment