Skip to content

Commit

Permalink
Add useConstraint modifier to the creation of the unique index.
Browse files Browse the repository at this point in the history
Knex documentation says for the unique() function, that useConstraint will use a unique constraint and is default true for postgres when there is no predicate defined.
Issue #3200 specifies that we want a unique index.
Documentation can be found here: https://knexjs.org/guide/schema-builder.html#unique
  • Loading branch information
thucdtran committed Jun 23, 2024
1 parent 8b8c1f2 commit 691834d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ exports.up = function (knex) {
table.foreign('grant_id').references('grants.grant_id');
table.foreign('user_id').references('users.id');

table.unique(['grant_id', 'user_id'], 'idx_grant_id_user_id');
table.unique(['grant_id', 'user_id'], {
indexName: 'idx_grant_id_user_id',
useConstraint: false,
});

Check failure on line 19 in packages/server/migrations/20240622205204_add-grant-notes-table.js

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

Expected indentation of 12 spaces but found 14
})
.createTable('grant_notes_revisions', (table) => {
table.increments('id').notNullable().primary();
Expand Down

0 comments on commit 691834d

Please sign in to comment.