Skip to content

Commit

Permalink
fixed migration build error
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Moses committed May 1, 2024
1 parent b8cc5ee commit fd67b0d
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function(knex) {
return knex.schema.alterTable('Questions', (table) => {
table.string('color').nullable();
});
exports.up = async function (knex) {
const hasColor = await knex.schema.hasColumn('Questions', 'color');
if (!hasColor) {
return knex.schema.alterTable('Questions', (table) => {
table.string('color').nullable();
});
}
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function(knex) {
return knex.schema.alterTable('Questions', (table) => {
table.dropColumn('color');
});
exports.down = async function (knex) {
const hasColor = await knex.schema.hasColumn('Questions', 'color');
if (hasColor) {
return knex.schema.alterTable('Questions', (table) => {
table.dropColumn('color');
});
}
};

0 comments on commit fd67b0d

Please sign in to comment.