traxxx/migrations/20240229054247_users_case.js

22 lines
520 B
JavaScript

exports.up = async (knex) => {
await knex.schema.alterTable('users', (table) => {
table.dropUnique('username');
});
await knex.raw(`
CREATE UNIQUE INDEX username_unique_index ON users (LOWER(username));
CREATE UNIQUE INDEX email_unique_index ON users (LOWER(email));
`);
};
exports.down = async (knex) => {
await knex.raw(`
DROP INDEX IF EXISTS username_unique_index;
DROP INDEX IF EXISTS email_unique_index;
`);
await knex.schema.alterTable('users', (table) => {
table.unique('username');
});
};