oms/backend/database/migrations/20260909000300-add-unique-email-on-users.js

17 lines
422 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/** 为 users.email 增加唯一索引(MySQL 唯一索引允许多个 NULL,历史空邮箱数据不受影响) */
module.exports = {
async up(queryInterface) {
await queryInterface.addIndex('users', {
fields: [ 'email' ],
unique: true,
name: 'uk_users_email',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('users', 'uk_users_email');
},
};