Skip to content

Commit

Permalink
fix(users): consider case insensitive username as unique constraint i…
Browse files Browse the repository at this point in the history
…n database

In the backend it is already validated that the `username` is unique ignoring the case; now this is
also validated in the database.
  • Loading branch information
Rafatcb committed Sep 4, 2024
1 parent ec17907 commit 1b78823
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
exports.up = (pgm) => {
pgm.dropConstraint('users', 'users_username_key');

pgm.createIndex('users', 'LOWER(username)', {
unique: true,
name: 'users_username_lower_idx',
});
};

exports.down = (pgm) => {
pgm.dropIndex('users', 'LOWER(username)', {
name: 'users_username_lower_idx',
});

pgm.addConstraint('users', 'users_username_key', {
unique: ['username'],
});
};

0 comments on commit 1b78823

Please sign in to comment.