Created
September 30, 2021 18:24
-
-
Save SidneyAllen/8d812f8ba2eb43b28393d843ec635692 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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