Created
February 4, 2022 17:58
-
-
Save mikepaszkiewicz/23c662e16e70d1d2b0555d4aaf2654dd to your computer and use it in GitHub Desktop.
Migration example
This file contains hidden or 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
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