Thanks to visit codestin.com
Credit goes to github.com

Skip to content

unique vs. dropUnique #292

@sebgie

Description

@sebgie

I've run across an inconsistent behavior when adding/removing unique constraints. I'm not sure if it is by intention? When I add a unique index to a table I use the name of the column I want to add it to. If I drop the index I need to know the name that was assigned?

Add a unique constraint to users.name

knex.schema.table('users', function (table) {
    table.unique('name');
})

Remove the previously added constraint

knex.schema.table('users', function (table) {
    table.dropUnique('users_name_unique');
})

I'm using knex 0.5.8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions