I'm looking to write a migration string to add a new string to the enum column type. I'm trying to add gamma
to the service
column.
I tried with this code below. This collides because the table and the column already exists.
const table = 'user_associations'
export function up (knex, Promise) {
return knex.schema.table(table, function (table) {
table.enu('service', ['alpha', 'beta', 'gamma']).notNullable()
})
}
export function down (knex, Promise) {
return knex.schema.table(table, function (table) {
table.enu('service', ['alpha', 'beta']).notNullable()
})
}
As of 2018-09-05, this is still an open issue: https://github.com/tgriesser/knex/issues/1699 (I believe you opened it!). If you're using PostgreSQL, then this is what I'd do:
$ psql
> \c ...
> \dt
to see all the tables> \d user_associations
to see all the info for that tableuser_associations_service_check
Then back in your migration:
This comment on your knexjs issue linked above has a clever utility function for accomplishing this: https://github.com/tgriesser/knex/issues/1699#issuecomment-402603481.