Skip to content

Instantly share code, notes, and snippets.

@mikepaszkiewicz
Created February 4, 2022 17:58
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 mikepaszkiewicz/23c662e16e70d1d2b0555d4aaf2654dd to your computer and use it in GitHub Desktop.
Save mikepaszkiewicz/23c662e16e70d1d2b0555d4aaf2654dd to your computer and use it in GitHub Desktop.
Migration example
import { Knex } from 'knex'
import { Territory } from '../packages/types'
exports.up = async function (knex: Knex) {
await knex.schema.hasTable('operators').then(async hasTable => {
if (hasTable) {
await knex.schema
.hasColumn('operators', 'send_tracker_link')
.then(async hasColumn => {
if (!hasColumn) {
await knex.schema.table('operators', t => {
t.boolean('send_tracker_link')
.defaultTo(false)
.notNullable()
})
}
})
}
})
}
exports.down = async function (knex: Knex) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment